
PHP performance: error suppression - nreece
http://vega.rd.no/article/php-performance-error-suppression
======
wvenable
The best thing to do is convert all your PHP errors into exceptions:

    
    
        function errorToExceptionHandler($errNo, $errStr, $errFile, $errLine, $errContext)
        {
            if (error_reporting() == 0) return;
            throw new ErrorException($errStr, 0, $errNo, $errFile, $errLine);
        }
    
        set_error_handler('errorToExceptionHandler');
    

You get a complete stack trace and try/catch handling of errors. It will throw
even for notices and warnings, but that's a good thing.

------
thomasmallen
Error suppression: bad. Exception handling: good. Some of my earliest code has
stuff like @mysql_query() because many books recommend this...and that's not
even a reasonable place to suppress an error!

~~~
jfarmer
Not only is it bad practice, but as the article points out, there is a
performance hit.

The reason is because @ makes the PHP engine switch between rendering modes.
Basically it's as if you have an extra <?php ?> in there.

Do that a lot and it adds up. So it's bad on every level.

