views:

217

answers:

2

In PHP error reporting,

  • E_ALL equals 8191 (1111111111111)
  • E_STRICT equals 2048 (100000000000)

Using bitwise OR to combine them:

1111111111111
 100000000000

we still get:

1111111111111

Why is the result of E_ALL | E_STRICT the same as E_ALL?

How does error_reporting() function distinguish between E_ALL | E_STRICT and E_ALL?

+7  A: 

You want:

error_reporting(E_ALL | E_STRICT);

E_ALL does not include E_STRICT (but it will in PHP 6+). Your values are incorrect. From Predefined Constants E_ALL is defined as:

All errors and warnings, as supported, except of level E_STRICT in PHP < 6.

32767 in PHP 6, 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously

cletus
I see this means the constant values will change as the version changes. The values I found is from http://www.w3schools.com/PHP/func_error_reporting.aspThey are very outdated, right?
bobo
w3schools can have some very outdated information. I would ALWAYS go to php.net as a first reference for anything PHP related.
cletus
+2  A: 

1 | 1 = 1

The simplest answer possible is that there's presently no reason to combine the two with a bitwise or operation, but if they ever decide to change those constants in the future, then there might be.

Edit: and you seem to have pulled the wrong values for those constants, making the entire question moot.

Azeem.Butt
Yes, I copied them from http://www.w3schools.com/PHP/func_error_reporting.asp
bobo