It seems PHP’s error suppressor @ is still triggering my custom error handler although it doesn’t show error’s on screen.
Example:
@json_decode(array());
This will not output error messages on screen but it will still run my error handler (e.g., log the error, send me email, terminate script execution, as if there was a “real” error).
Is there a way for @ to totally be silent?
I don’t believe you can prevent the error handler from seeing errors that were suppressed by
@.You can however isolate those errors and ignore them at your own risk.
Put the following code in your error handler:
Note that
$errnois the first argument to the error handler callback.