View @ suppressed errors in php

I know that you can use @ to suppress errors. But anyway, can you do php ignore @?

In my case, I have to use the 3rd side of the script, which uses @, the script is huge, and it's hard for me to find where it dies.

+4
source share
6 answers

When you use the PHP Xdebug extension, you can ignore error management of the @ operator using this configuration parameter :

 xdebug.scream = 1 

This disables the @ (shut-up) statement so that notifications, warnings, and errors are no longer hidden.

+6
source

There is a scream extension to turn off silence.

+4
source

Each custom error handler receives suppressed error messages:

 set_error_handler("var_dump"); 

Just an example. Usually you choose a more convenient reporting function.

+2
source

But still you can do php ignore @?

I don’t think so, no, not without an extension, as @deceze showed.

However, you can configure a custom error handler . If you configure this to ignore the error_reporting() parameter, which is 0 when inside the function that was called with @ , you can output an error there.

+1
source

you can use

 print_r(error_get_last()); 

to get the last generated error after the script so you can catch suppressed errors.

Further reading error_get_last ()

+1
source
 ini_set('scream.enabled', true); 

You need to install the vi extension:

http://www.php.net/manual/en/book.scream.php

0
source

Source: https://habr.com/ru/post/1342266/


All Articles