导致php.ini忽略error_reporting指令的原因


What could cause php.ini to ignore error_reporting directive?

因此,当我在php.ini 中设置此指令时

error_reporting=E_ALL&已弃用的(_E)

即使在apache重新加载或重新启动之后,我仍然会收到这些错误。

Thu Sep 13 10:51:10 2012]〔error〕〔client 173.529.24〕PHP不推荐:在中不推荐通过引用分配new的返回值

等等

有什么想法吗?我不知道为什么php.ini不会听这个指令来不列出不推荐使用的内容。

PHP 5.3.3(cli)(构建时间:2012年7月3日16:53:21)版权所有(c)1997-2010 PHP集团Zend Engine v2.3.0,版权所有(c)1998-2010 Zend Technologies

这花了我很长时间进行调试。由旧版本的phprunner生成的代码,由于"弃用函数mysql_connect"而崩溃。但无论我对error_reporting 做了什么

error_reporting(E_ALL & ~E_DEPRECATED); // was being ignored

这是因为代码使用了自己的错误处理功能"错误处理程序"

set_error_handler("my_error_handler"); // override error_reporting()

我所要做的就是添加以下行到函数my_error_handler()

if ($errno==8192) return 0;   // ignore Deprecated

我浪费了很多时间摆弄php.ini,但它与它无关!

error_reporting可能在脚本中的某个地方被调用。

你可以用这个在错误发生之前重置它:

error_reporting(E_ALL & ~E_DEPRECATED);

我的解决方案与zzapper相同-phprunner的文件名为phpfunctions.php,这很有效:

if ($errno==8192) return 0;   // ignore Deprecated

有几个地方可以更改此设置的值,包括常见的ini_seterror_reporting函数。有人正在从其中一个更改它。