How to tell if an error was suppressed by the @ error control operator?

主宰稳场 提交于 2019-12-11 23:56:29

问题


A 3rd party library I'm using uses the @ error suppression operator in its codes which causes suppressed errors via @ still cause an error output because I am using a custom error handler (set_error_handler()).

In this page it says

If you have set a custom error handler function with set_error_handler() then it will still get called, but this custom error handler can (and should) call error_reporting() which will return 0 when the call that triggered the error was preceded by an @.

However it is unclear how exactly can I catch the errors that was preceded by an @.

My question is how can I catch errors that was suppressed via @?


回答1:


As it says: your error handler will still be invoked as usual, but calling error_reporting() inside your error handler will yield 0 if the error was produced in the context of an @. So your error handler should take that into account and act accordingly.



来源:https://stackoverflow.com/questions/52550522/how-to-tell-if-an-error-was-suppressed-by-the-error-control-operator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!