What's the point of E_ALL | E_STRICT if it's the same value as E_ALL?

自闭症网瘾萝莉.ら 提交于 2019-12-01 15:26:21
cletus

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

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.

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.

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);

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!