Click here to get back home

@some_function

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
@some_function Jeff 07-29-2008
Get Chitika Premium
Posted by Jeff on July 29, 2008, 11:45 am
Please log in for more thread options
I'm looking through the GD sample code and I'm seeing things like this:

$src=@imagecreatefromjpeg($spath);

I don't understand the "@". And I don't see a reference to it in the
manual, I suppose that's because I don't know what it's called!

Jeff

Posted by Erwin Moller on July 29, 2008, 11:49 am
Please log in for more thread options
Jeff schreef:
> I'm looking through the GD sample code and I'm seeing things like this:
>
> $src=@imagecreatefromjpeg($spath);
>
> I don't understand the "@". And I don't see a reference to it in the
> manual, I suppose that's because I don't know what it's called!
>
> Jeff

Hi Jeff,

Yes, these short of things can be hard to find if you don't know what
they are supposed to do.

In this case: It is an error suppression mechanism.
Read more here:
http://nl2.php.net/manual/en/language.operators.errorcontrol.php

Regards,
Erwin Moller

Posted by Gordon on July 29, 2008, 12:29 pm
Please log in for more thread options
> I'm looking through the GD sample code and I'm seeing things like this:
>
> $src=@imagecreatefromjpeg($spath);
>
> I don't understand the "@". And I don't see a reference to it in the
> manual, I suppose that's because I don't know what it's called!
>
> Jeff

It's the error suppression operator. Any function that has this
symbol prepended will not print an error message to the browser if it
fails.

The error suppression operator carries quite a significant performance
hit, unfortunately, so it's not really recommended for use unless you
have no alternative. In an ideal world the way to keep error messages
appearing in the browser is to turn off error_reporting in php.ini or
your web server configuration (in Apache this can be done from
httpd.conf or from .htaccess files if they're enabled) and check the
success or otherwise of functions yourself. The @ operator all over
the place should be considered a PHP code smell, as it indicates that
there might be problems with how the programmer is dealing with
abnormal conditions, and it certainly means you're paying a
performance cost.


Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap