PHPWomen Site Home » Programming » Best Practices » Why @ is NOT your friend
Why @ is NOT your friend [message #1372] Mon, 02 July 2007 18:56 Go to next message
auroraeosrose  is currently offline auroraeosrose
Messages: 89
Registered: October 2006
Location: Sturgis, Michigan
Junior Member
Ah, the error suppression operator (@)

It seems like such a fantastic idea, just put it in front of your function and no more error, right?

Well, kind of...

In order to understand the @ operator you need to understand a bit of how the php engine works. That @ doesn't really "suppress" the error, instead it turns error_reporting to 0, performs the activity, and turns error_reporting back to what it was originally.

Seriously, that's all it does, and it does it slowly (in other words, it works faster to make those error_reporting calls yourself). Also remember that if you have a custom error_handler registered you have to check to see if @ was used by calling if(error_reporting() == 0) at the start of your handler....

Bottom line? It's better to work around the error if at all possible, check to see if a file exists before working on it, handle errors in your db code properly.

@ is NOT your friend Wink
Re: Why @ is NOT your friend [message #1377 is a reply to message #1372 ] Mon, 02 July 2007 23:01 Go to previous message
KathyReid  is currently offline KathyReid
Messages: 224
Registered: October 2006
Location: Geelong, Victoria, Austra...
Member
Great article!
There are other articles on error handling here as well;
http://www.phpwomen.org/forum/index.php?t=msg&th=245& ;start=0&S=634b6cfeb36da964e087cf42f52b4e06
Previous Topic:PHP Best Practices - kicking off
Next Topic:suggestion: php and forms
Goto Forum:
  


Current Time: Fri Jul 30 13:03:33 EDT 2010

Total time taken to generate the page: 0.00963 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.0.
Copyright ©2001-2006 FUD Forum Bulletin Board Software