Suppressing errors with PHP's @ operator

25
Nov

Don't do it.

I know this has been covered in various places around the Interwebs, but I'd like to add my voice to the chorus - every time you use @ to suppress a warning or error you can't be bothered dealing with, a puppy dies. There is essentially no good reason to use it, and if it ends up suppressing an unforseen yet important error, you're going to have a nightmare of a time trying to track it down.

The best way to handle it is to use Exceptions, handle the states that cause the errors manually, or turn off warnings/notices at the PHP configuration level. Don't use @. It's bad bad practice, and it will come back to haunt you one day.

Comments

Haha, I saw the title in my feed reader and came in guns drawn - good call, Cameron.

Post new comment

The content of this field is kept private and will not be shown publicly.
Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.