为什么即使有error_reporting(0),PHP也会回显错误的原因是什么? [英] What are the reasons why PHP would echo errors, even with error_reporting(0)?

查看:208
本文介绍了为什么即使有error_reporting(0),PHP也会回显错误的原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无论您叫它禁用什么,PHP都会强制显示错误的原因有哪些?

What are some reasons why PHP would force errors to show, no matter what you tell it to disable?

我尝试过

error_reporting(0);
ini_set('display_errors', 0); 

没有运气.

推荐答案

请注意手册中的注意事项,网址为 http://uk.php.net/error_reporting :

Note the caveat in the manual at http://uk.php.net/error_reporting:

大多数E_STRICT错误是在编译时评估的,因此在将error_reporting增强为包括E_STRICT错误的文件中不会报告此类错误(反之亦然).

Most of E_STRICT errors are evaluated at the compile time thus such errors are not reported in the file where error_reporting is enhanced to include E_STRICT errors (and vice versa).

如果您的基础系统配置为报告E_STRICT错误,则可能在考虑代码之前就输出了这些错误.别忘了,error_reporting/ini_set是运行时评估,在运行前"阶段执行的任何操作都不会看到它们的影响.

If your underlying system is configured to report E_STRICT errors, these may be output before your code is even considered. Don't forget, error_reporting/ini_set are runtime evaluations, and anything performed in a "before-run" phase will not see their effects.

根据您的评论,您的错误是...

Based on your comment that your error is...

解析错误:语法错误,意外的T_VARIABLE,期望为','或';'在第11行的/usr/home/REDACTED/public_html/dev.php中

Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /usr/home/REDACTED/public_html/dev.php on line 11

然后应用相同的一般概念.您的代码从不运行,因为它在语法上是无效的(您忘记了;").因此,永远不会遇到您的错误报告更改.

Then the same general concept applies. Your code is never run, as it is syntactically invalid (you forgot a ';'). Therefore, your change of error reporting is never encountered.

要解决此问题,需要更改系统级错误报告.例如,在Apache上,您可以放置​​...

Fixing this requires a change of the system level error reporting. For example, on Apache you may be able to place...

php_value错误报告0

php_value error_reporting 0

.htaccess文件中的所有内容可将其全部删除,但这取决于系统配置.

in a .htaccess file to suppress them all, but this is system configuration dependent.

实用上,请勿写入语法错误的文件:)

Pragmatically, don't write files with syntax errors :)

这篇关于为什么即使有error_reporting(0),PHP也会回显错误的原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆