php phpinfo的error_reporting 22527中的22527是什么
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4678082/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is 22527 in error_reporting 22527 of phpinfo
提问by shin
In my local dev env, I use PHP Version 5.3.3-1ubuntu9.2.
在我的本地开发环境中,我使用 PHP 版本 5.3.3-1ubuntu9.2。
Now when I see error_reporting, the value is 22527.
现在,当我看到 error_reporting 时,该值为 22527。
What is 22527?
什么是22527?
I checked http://www.php.net/manual/en/errorfunc.constants.php, but I could not find the number.
我检查了http://www.php.net/manual/en/errorfunc.constants.php,但我找不到号码。
Could anyone tell me what it is?
谁能告诉我它是什么?
Do I need to change it to E_ALL | E_STRICT ?
我是否需要将其更改为 E_ALL | E_STRICT ?
Thanks in advance.
提前致谢。
回答by German Rumm
This value is actually bitmap mask, a sum of constants.
这个值实际上是位图掩码,常量的总和。
So, 22527 is
所以,22527 是
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
.
在您的情况下E_ALL & ~E_DEPRECATED
,它会显示每个错误,除了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)
低于 5.4 的 PHP 版本也将排除E_STRICT
错误(因为在该版本之前E_STRICT
不包括在内E_ALL
)
回答by Salman A
This value is one or more of these constantsbitwise-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:
phpinfo()
通常显示数值而不是 INI 文件中使用的常量或速记。这是将值映射回常量的示例:
<?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
回答by Buttle Butkus
NEVER use the numeric value to set your error reporting, as the meaning of that value can changebut the meaning of the constants (like E_ALL, E_STRICT, etc) likely will not:
切勿使用数值来设置错误报告,因为该值的含义可能会改变,但常量(如 E_ALL、E_STRICT 等)的含义可能不会:
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.
新的 error_reporting 级别。它采用位掩码或命名常量。强烈鼓励使用命名常量以确保未来版本的兼容性。随着错误级别的增加,整数的范围会增加,因此旧的基于整数的错误级别并不总是按预期运行。
(and note that as of PHP 5.4, E_ALL now includes E_STRICT)
(请注意,从 PHP 5.4 开始,E_ALL 现在包含 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:
如果您想要永远最严格的报告,您可以将 error_reporting 设置为一个非常大的数字,以保证(?)您将永远报告所有错误:
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).
在 PHP 之外使用 PHP 常量,如在 httpd.conf 中,将没有任何有用的意义,因此在这种情况下需要整数值。而且由于错误级别会随着时间的推移而增加,最大值(对于 E_ALL)可能会发生变化。因此,代替 E_ALL考虑使用更大的值来覆盖从现在到未来的所有位字段,一个像 2147483647 这样的数值(包括所有错误,而不仅仅是 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.
检查您的 php.ini 中的 error_reporting 值,以人类可读的 PHP 常量格式。phpinfo() 函数似乎总是显示数值而不是常量。
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.:
但是,就个人而言,我将 php.ini 保留为错误报告的默认值。相反,我只是将错误报告功能放在我正在处理的任何 php 脚本的顶部以覆盖默认值。例如:
error_reporting(E_ALL | E_STRICT);