开发者

Prevent calls to error_reporting() and/or ini_set('display_errors', 'On') from overriding php.ini settings

I had this setting in my php.ini file:

error_repor开发者_如何学运维ting = E_ERROR|E_PARSE|E_CORE_ERROR|E_COMPILE_ERROR

But I was still receiving thousands of NOTICE and WARNING entries in the error log every minute. I of course realize I would better deal with those errors, but this is not my code and I am not being paid to do that, I just needed to get rid of those fat error_log files (Gbs per day).

I searched through the code and removed all error_reporting() calls, and that did the trick but, is there a way to disallow error_reporting() from overriding php.ini settings?

Could I also prevent calls to ini_set('display_errors') from overriding php.ini settings?


is there a way to disallow error_reporting() from overriding php.ini settings?

Maybe.

If you're using mod_php under Apache (or FastCGI via FPM), you can use php_admin_value and php_admin_flag to force certain INI settings in such a way that ini_set will be unable to override.

Unfortunately I don't know of a way to neuter error_reporting other than disable_functions -- but this will throw a PHP Warning every time it's used.

(As a side note, I find it curious that a developer would set an error reporting level in production and still be producing such a high volume of logs.)


You could try the disable_functions php.ini setting and turn off error_reporting() and ini_set(). But that COMPLETELY disables them, so if you need to change settings other than error_reporting at runtime, you'd be SOL.


According to the following pages, the PHP engine sets when and where a configuration option can be set. There is no way to prevent it programmatically:

http://www.php.net/manual/en/configuration.changes.modes.php http://php.net/manual/en/errorfunc.configuration.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜