tags:

views:

163

answers:

3
// Get the image information and display the image:
 if ($image = @getimagesize ("../uploads/$pid")) {
  echo "<div align=\"center\"><img src=\"show_image.php?image=$pid&name=" . urlencode($row['image_name']) . "\" $image[3] alt=\"{$row['print_name']}\" /></div>\n"; 
 } else {
  echo "<div align=\"center\">No image available.</div>\n"; 
 }

What does @ do in @getimagesize?

+8  A: 

It stops errors from being displayed and/or being logged from that specific function call.

Jake
A: 

It suppress errors to appear. If the command you are invoking has an error or a warning to state, you will not get any printout in the page. You can also see it used with mysql_* routines.

Stefano Borini
+16  A: 

It is an Error Control Operator, that will mask (prevent from being displayed) any error the getimagesize function could generate.

It it generally not considered a good practice to use it : it makes your code really harder to debug (if there is an error, you won't know about it) :

Currently the "@" error-control operator prefix will even disable error reporting for critical errors that will terminate script execution. Among other things, this means that if you use "@" to suppress errors from a certain function and either it isn't available or has been mistyped, the script will die right there with no indication as to why.

There is even a PHP extension, called scream, that disables this operator -- can be pretty useful when you are maintaintaing an apllication that used this operator a lot...

Generally, it is better to set error_reporting (see also) level and display_errors so that errors are displayed in development, and not in production -- that's way more useful that just always hiding them !

Pascal MARTIN