How to see errors suppressed by "@"?

I joined this crazy company as a site administrator. Now I have made some changes to my db configurations that have affected the execution of PHP scripts.

The weird part is the PHP scripts that just die. They do not throw any mistakes. When I entered the scripts, I realized that they used the @error suppression directive. Now the whole code base is a million lines spread across thousands of files, and you don’t want to run something like sed to replace β€œ@”.

But "@" makes debugging impossible for me. Such developers close their eyes and see that the darkness of darkness speaks of its night.

Is there a way that I can cancel the error suppression made with '@' and enable the php log directive. Touching the codebase is not an option. I am looking forward to the way I can do this by modifying the php configuration or adding a few lines to the bootstrap file.

+8
php error-handling
source share
2 answers

If you have Xdebug installed and enabled, then you can install xdebug.scream , which disables the @ -operator.

As an alternative to screaming, the PECL extension also disables the @ -operator (and all that it does).

You basically install the extension, and then set the scream.enabled ini parameter to true / on.

+5
source share

Disabled errors are still visible for the handler set via set_error_handler . So you can just add something like this to your bootstrap file:

 set_error_handler(function ($errno, $errstr, $errfile, $errline) { echo "$errstr at $errfile($errline)\n"; }); 

or better

 set_error_handler(function ($errno, $errstr, $errfile, $errline) { throw new ErrorException($errstr, $errno, 1, $errfile, $errline); }); 

which also displays the stack.

+4
source share

All Articles