TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   What's @ doc ? (http://www.talkphp.com/absolute-beginners/2783-whats-doc.html)

JabberGabber 05-08-2008 07:07 PM

What's @ doc ?
 
Hi

In some code examples I have seen some functions have been preceded with the @ symbol:

$image = @imagecreatefromjpeg('image.jpg');

What's all that about then ??

Thanks in advance

JabberGabber

Salathe 05-08-2008 08:53 PM

The @ symbol is an error control operator, it suppresses the display of any error messages which might occur. Full details can be found on the PHP manual page Error Control Operators.

JabberGabber 05-08-2008 09:20 PM

Excellent - thanks for that.

drewbee 05-12-2008 09:20 PM

Exactly! It is very useful especially when certain conditions may exist.

For instance, if you expect an error to occur out of a function (XML Parsing comes to mind and being fed bad data), or if an error could potentially occur, but you want it to fail silently and continue on IE database connections. Should a database connection occur and you supress it correctly, instead of getting the default could not connect message, you can make it all pretty and stuff with a custom error handler, or use the OR DIE() function... but thats another topic


All times are GMT. The time now is 06:25 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0