Home

Suppressing errors with PHP's @ operator

by Cameron

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.

November25
Submitted by Anonymous (not verified) on Thu, 11/26/2009 - 00:21.

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.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
11 + 9 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.