Search code examples
phpfpm

Disallow PHP code overriding php.ini error_reporting


Can i disallow PHP override php.ini error_reporting settings? And take this settings only from php.ini.

php.init file have: error_reporting = E_ERROR|E_PARSE

PHP code have: error_reporting(E_WARNING|E_PARSE);

But this PHP line is in project core and i can't edit it and I don't need E_WARNING.


Solution

  • Can i disallow PHP override php.ini error_reporting settings?

    You can disallow use of error_reporting() function in your code with use of disable_functions configuration directive. The downside is that you cannot have

    disable_functions = error_reporting
    

    set per vhost (i.e. via php_admin_value) but it must be set in main php.ini which may be problematic in some configurations.

    Also I believe that your question exposed different problem and you are not fixing it here, but rather working around.