如何判断错误是否被@错误控制运算符抑制了?

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

我正在使用的第 3 方库在其代码中使用了 @ 错误抑制运算符,这导致通过 @ 抑制错误仍然导致错误输出,因为我使用的是自定义错误处理程序 (set_error_handler()).

在这个 page 中说

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 @.

但是我不清楚如何准确地捕捉到前面有 @ 的错误。

我的问题是如何捕获通过 @ 抑制的错误?

正如它所说:您的错误处理程序仍将像往常一样被调用,但是如果错误是在 @.所以你的错误处理程序应该考虑到这一点并采取相应的行动。