-1

I have a very old system running with an old php version. In order to check the website i have to suppress all errors, warnings, Deprecated etc. messages. Unfortunately there a lots of ini_set("display_errors", "1"); inside the code all over the system.

Is it possible to suppress everything no matter what a php script calls? Maybe with the php.ini or htaccess?

I already disabled "display_errors" in the php.ini. But that didnt help.

webGuy
  • 121
  • 2
  • 9

2 Answers2

0

For the best error logging experience, set error_reporting to -1, turn display_errors off, and set a custom error_log location so it doesn't mix in with other sites you may be building.

After doing that, you should find and delete the display error ini_set() calls.

Then in the terminal, type tail -f /path/to/error_log. Your notices, warnings and errors will now scroll past in real time, without distorting your web page's display.

This way, you can still see what needs refactored/fixed in a much tidier log format, but without the mess all over your page!

delboy1978uk
  • 10,948
  • 2
  • 14
  • 31
0

It don't see particularly daunting to search and comment out all ini_set("display_errors", "1"); calls but the alternative would be write a custom error handler (or edit the existing one):

<?php

ini_set('display_errors', 1);
error_reporting(-1);

function ignore_errors($errno, $errstr, $errfile, $errline){
    // Optional error processing
    return true;
}

$foo++;

set_error_handler('ignore_errors');

$bar++;
Notice: Undefined variable: foo in C:\...\scratch_7.php on line 11

If there're too many entry points, you can always call an external file with the auto_prepend_file directive in your main php.ini file.

Álvaro González
  • 128,942
  • 37
  • 233
  • 325