编程语言
首页 > 编程语言> > 即使使用error_reporting(0),PHP会回显错误的原因是什么?

即使使用error_reporting(0),PHP会回显错误的原因是什么?

作者:互联网

PHP会强制显示错误的原因是什么,无论你告诉它禁用什么?

我努力了

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

没有运气.

解决方法:

请注意0​​7000手册中的警告:

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是运行时评估,在“运行前”阶段执行的任何操作都不会看到它们的影响.

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

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

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

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

php_value error_reporting 0

在.htaccess文件中将它们全部压缩,但这取决于系统配置.

实际上,不要写出语法错误的文件:)

标签:error-reporting,php,ini-set
来源: https://codeday.me/bug/20191005/1857777.html