Question

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.

Was it helpful?

Solution

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)

OTHER TIPS

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);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top