#! /usr/local/bin/php
PHP's error_reporting ini setting uses bitwise values,
providing a real-world demonstration of turning
bits off. To show all errors, except for notices,
the php.ini file instructions say to use:
E_ALL & ~E_NOTICE
This works by starting with E_ALL:
00000000000000000111111111111111
Then taking the value of E_NOTICE...
00000000000000000000000000001000
... and inverting it via ~:
1111111111111111111111111111111111111111111111111111111111110111
Finally, it uses AND (&) to find the bits turned
on in both values:
00000000000000000111111111110111
Another way to accomplish that is using XOR (^)
to find bits that are on in only one value or the other:
E_ALL ^ E_NOTICE
error_reporting can also be used to demonstrate turning bits on.
The way to show just errors and recoverable errors is:
E_ERROR | E_RECOVERABLE_ERROR
This process combines E_ERROR
00000000000000000000000000000001
and
00000000000000000001000000000000
using the OR (|) operator
to get the bits turned on in either value:
00000000000000000001000000000001