开发者

What is 22527 in error_reporting 22527 of phpinfo

In my local dev env, I use PHP Version 5.3.3-1ubuntu9.2.

Now when I see error_reporting, the value is 22527.

What is 22527?

I checked http://www.php.net/manual/en/errorfunc.constants.php, but I could not find the number.

Could anyone tell me what it is?

开发者_如何转开发

Do I need to change it to E_ALL | E_STRICT ?

Thanks in advance.


This value is actually bitmap mask, a sum of constants.

So, 22527 is

  16384 E_USER_DEPRECATED
+
  4096  E_RECOVERABLE_ERROR
+
  etc...

In your case it's E_ALL & ~E_DEPRECATED, it will display every error, except E_DEPRECATED.

PHP versions below 5.4 will also exclude E_STRICT errors (since E_STRICT is not included in E_ALL before that version)


This value is one or more of these constants bitwise-ored together.

phpinfo() usually displays the numeric value instead of the constants or shorthands used inside INI files. Here is an example to map the value back to constants:

<?php
$error_reporting_value = 22527;
$constants = array(
    "E_ERROR",
    "E_WARNING",
    "E_PARSE",
    "E_NOTICE",
    "E_CORE_ERROR",
    "E_CORE_WARNING",
    "E_COMPILE_ERROR",
    "E_COMPILE_WARNING",
    "E_USER_ERROR",
    "E_USER_WARNING",
    "E_USER_NOTICE",
    "E_STRICT",
    "E_RECOVERABLE_ERROR",
    "E_DEPRECATED",
    "E_USER_DEPRECATED",
    "E_ALL"
);
$included = array();
$excluded = array();
foreach ($constants as $constant) {
    $value = constant($constant);
    if (($error_reporting_value & $value) === $value) {
        $included[] = $constant;
    } else {
        $excluded[] = $constant;
    }
}
echo "error reporting " . $error_reporting_value . PHP_EOL;
echo "includes " . implode(", ", $included) . PHP_EOL;
echo "excludes " . implode(", ", $excluded) . PHP_EOL;

Output:

error reporting 22527
includes E_ERROR, E_WARNING, E_PARSE, E_NOTICE, E_CORE_ERROR, E_CORE_WARNING, E_COMPILE_ERROR, E_COMPILE_WARNING, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE, E_RECOVERABLE_ERROR, E_USER_DEPRECATED
excludes E_STRICT, E_DEPRECATED, E_ALL


NEVER use the numeric value to set your error reporting, as the meaning of that value can change but the meaning of the constants (like E_ALL, E_STRICT, etc) likely will not:

The new error_reporting level. It takes on either a bitmask, or named constants. Using named constants is strongly encouraged to ensure compatibility for future versions. As error levels are added, the range of integers increases, so older integer-based error levels will not always behave as expected.

(and note that as of PHP 5.4, E_ALL now includes E_STRICT)

IF you want the strictest reporting forever and ever, you could set error_reporting to a very large number in order to guarantee(?) that you will report all errors forever :

Using PHP Constants outside of PHP, like in httpd.conf, will have no useful meaning so in such cases the integer values are required. And since error levels will be added over time, the maximum value (for E_ALL) will likely change. So in place of E_ALL consider using a larger value to cover all bit fields from now and well into the future, a numeric value like 2147483647 (includes all errors, not just E_ALL).

Check your php.ini for the value of error_reporting in human-readable PHP constants format. The phpinfo() function appears to always show the numeric value rather than showing the constants.

But, personally, I leave php.ini with the default values for error reporting. Instead I just put the error reporting function at the top of whatever php script I'm working on to override the defaults. e.g.:

error_reporting(E_ALL | E_STRICT);


$ php -i | grep error_reporting

o/p is 22527

Go To https://maximivanov.github.io/php-error-reporting-calculator/

Enter 22527 in Resulting Error Level box.

O/p is E_ALL & ~E_STRICT & ~E_DEPRECATED

OR

$arr = array_flip(array_slice(get_defined_constants(true)['Core'], 0,15));   
$needToRemove = array('E_ALL','E_STRICT','E_DEPRECATED');
$filtered = array_diff($arr, $needToRemove);
print_r($filtered);
echo array_sum(array_flip($filtered));

o/p is

Array
(
    [1] => E_ERROR
    [4096] => E_RECOVERABLE_ERROR
    [2] => E_WARNING
    [4] => E_PARSE
    [8] => E_NOTICE
    [16] => E_CORE_ERROR
    [32] => E_CORE_WARNING
    [64] => E_COMPILE_ERROR
    [128] => E_COMPILE_WARNING
    [256] => E_USER_ERROR
    [512] => E_USER_WARNING
    [1024] => E_USER_NOTICE
    [16384] => E_USER_DEPRECATED
)

22527

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜