尽管未设置但抛出 E_STRICT 消息
自从将我的测试服务器更新到 PHP 5.3.3 (Debian Squeeze) 以来,我遇到了有关 PHP 错误报告的奇怪行为。
我像这样设置 error_reporting:
error_reporting(E_ALL);
并通过 echoes 30719
检查设置
echo error_reporting();
。根据 php.net 这意味着“所有受支持的错误和警告,除了级别 E_STRICT。”。
但在下一行(类定义abstract class formInputContainer extends formContainer Implements formElementValueable { ... }
)中,会产生以下消息:
严格(2048):formInputContainer::addElement()的声明应该与formContainer::addElement()的声明兼容
为什么 E_STRICT 消息虽然没有设置却会被回显?甚至更改为 E_ALL & ~E_STRICT 没有帮助。
Since updating my testing server to PHP 5.3.3 (Debian Squeeze) I encountered strange behaviour regarding the error reporting in PHP.
I set error_reporting like this:
error_reporting(E_ALL);
and checked the setting via
echo error_reporting();
which echoes 30719
. According to php.net this means "All errors and warnings, as supported, except of level E_STRICT.".
But in the very next line (a class definition abstract class formInputContainer extends formContainer implements formElementValueable { ... }
) this results in the message:
Strict (2048): Declaration of formInputContainer::addElement() should be compatible with that of formContainer::addElement()
Why is the E_STRICT message echoed though it's not set? Even changing to E_ALL & ~E_STRICT does not help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管未设置它们,但您看到它们的原因是它们是在编译时(好吧,解析时)抛出的。这意味着错误会在调用
error_reporting()
之前触发。真正的解决方法是更改php.ini
设置以从定义中删除E_STRICT
。为了确保您编辑的是正确的文件,请检查phpinfo()
。The reason you're seeing them even though they are not set, is that these are thrown at compile time (well, parse time). That means the errors are triggered before your
error_reporting()
call is made. The real fix is to change thephp.ini
setting to removeE_STRICT
from the definition. To make sure you're editing the correct file, checkphpinfo()
.如果这是自定义错误处理程序(通过
set_error_handler()
设置),您必须自行检查当前的error_reporting
级别。自定义错误处理程序获取所有错误消息:手册说:
If this is a custom error handler (set via
set_error_handler()
), you'll have to check the currenterror_reporting
level by yourself. A custom error handler gets all error messages:The manual says: