11
  • E_ALL equals 8191 (0001 1111 1111 1111)
  • E_STRICT equals 2048 (0000 1000 0000 0000)

Using bitwise OR to combine them:

1 1111 1111 1111
  1000 0000 0000

We get the exact same value as the original E_ALL:

1 1111 1111 1111

What's the point of doing error_reporting(E_ALL | E_STRICT) if we can simply do error_reporting(E_ALL) to get the same thing?

Pacerier
  • 86,231
  • 106
  • 366
  • 634
bobo
  • 8,439
  • 11
  • 57
  • 81
  • I've noticed that with 5.4 that I can do the following 1. Set E_ALL in php.ini and then E_ALL | E_STRICT 2. Check phpinfo() and the value for error reporting is the same. This seems like a bug to me.... – Alex Waters Oct 25 '12 at 07:55
  • 1
    use https://maximivanov.github.io/php-error-reporting-calculator/ to create error reporting of your choice – pkachhia May 24 '17 at 06:44

4 Answers4

19

You want:

error_reporting(E_ALL | E_STRICT);

E_ALL does not include E_STRICT (unless you are using PHP 5.4+). Your values are incorrect. From Predefined Constants E_ALL is defined as:

All errors and warnings, as supported, except of level E_STRICT prior to PHP 5.4.

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

alxgb
  • 543
  • 8
  • 18
cletus
  • 616,129
  • 168
  • 910
  • 942
  • 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.asp They are very outdated, right? – bobo Oct 28 '09 at 16:20
  • 12
    w3schools can have some very outdated information. I would ALWAYS go to php.net as a first reference for anything PHP related. – cletus Oct 28 '09 at 16:27
  • 3
    In PHP 5.4, `E_STRICT` is included in `E_ALL`. – apaderno Nov 30 '12 at 02:38
3

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
  • 5,855
  • 1
  • 26
  • 22
1

from php.net:

Passing in the value -1 will show every possible error, even when new levels and constants are added in future PHP versions. The E_ALL constant also behaves this way as of PHP 5.4.

Lan
  • 1,874
  • 2
  • 20
  • 37
1

The bit values provided in the question are not generally wrong but only for PHP versions older than 5.4.

PHP 5.4+

E_ALL includes E_STRICT so you should use: error_reporting(E_ALL);

Binary                  Name       Decimal
0001 1111 1111 1111     E_ALL      32767
0000 1000 0000 0000     E_STRICT   2048
----------------------------------------------------------------------
0001 1111 1111 1111     E_ALL | E_STRICT produces the same result as E_ALL

PHP 5.3

E_ALL does not include E_STRICT so you should use: error_reporting(E_ALL | E_STRICT);

Binary                  Name       Decimal
0111 0111 1111 1111     E_ALL      30719
0000 1000 0000 0000     E_STRICT   2048
----------------------------------------------------------------------
0111 1111 1111 1111     E_ALL | E_STRICT produces a different value than E_ALL

PHP 5.0 till 5.2

E_ALL does not include E_STRICT so you should use: error_reporting(E_ALL | E_STRICT); but the bit values differ from the values in PHP 5.3.

PHP before 5.0

E_STRICT does not exist so you must use: error_reporting(E_ALL);

Michael Käfer
  • 1,597
  • 2
  • 19
  • 37