3

I'm wondering if at the server level I can disable the ability for scripts to override error_reporting and ini_set('display_errors',1);

Edit: I know how to disable errors using .htaccess and on a script by script basis. What I am trying to do is disable the ability to override error settings entirely so our developers actually fix their issues and not hide behind a error_reporting(0); ini_set('display_errors', 0);

6

You should be able to use the disable functions feature built into PHP. That will prevent them from even calling ini_set or error_reporting in the first place.

Add to php.ini:

disable_functions = error_reporting,ini_set,shell_exec,etc...

  • One issue I have with this is we want to disable write access to error_reporting, but read access should be OK. – BaseZen Mar 15 '18 at 18:30
-1

If you add these lines to your .htaccess it should do the job for the entire site.

php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
php_flag  log_errors off

If you want to do it on a script by script basis

From the PHP manual at http://php.net/manual/en/function.error-reporting.php and found by doing a search for 'disable php error reporting'

error_reporting(0);
  • 2
    I'm trying to disable the ability to set error_reporting entirely. We have lazy programmers who hide their crap code by setting error_reporting(0) at the top of their files and I want to completely disable their ability to do that. – Peter Apr 27 '16 at 6:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.