开发者

View @ supressed errors in php

开发者 https://www.devze.com 2023-02-15 06:08 出处:网络
I know you can use @ to suppress errors开发者_开发知识库. But is there anyway you can make php ignore @ ?

I know you can use @ to suppress errors开发者_开发知识库. But is there anyway you can make php ignore @ ?

In my case, I have to use a 3th party script that uses @, the script is huge and I'm having a hard time finding out where it dies.


When you use the PHP Xdebug extension you can ignore the error control operator @ by using this config setting:

xdebug.scream = 1

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


There's the scream extension to break the silence.


Every custom error handler receives suppressed error messages:

set_error_handler("var_dump");

Just an example. You would normally choose a nicer reporting function.


But is there anyway you can make php ignore @ ?

I don't think so, no, not without an extension as shown by @deceze.

You could set up a custom error handler though. If you configure that to ignore the error_reporting() setting, which is 0 when inside a function that was called with @, you can output the error there.


You can use

print_r(error_get_last());

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

Further reading error_get_last()


ini_set('scream.enabled', true);

You need to install the scream pecl extension:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消