@some_function

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    @some_function

    I'm looking through the GD sample code and I'm seeing things like this:

    $src=@imagecrea tefromjpeg($spa th);

    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
  • Erwin Moller

    #2
    Re: @some_function

    Jeff schreef:
    I'm looking through the GD sample code and I'm seeing things like this:
    >
    $src=@imagecrea tefromjpeg($spa th);
    >
    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:


    Regards,
    Erwin Moller

    Comment

    • Gordon

      #3
      Re: @some_function

      On Jul 29, 4:45 pm, Jeff <jeff@spam_me_n ot.comwrote:
      I'm looking through the GD sample code and I'm seeing things like this:
      >
      $src=@imagecrea tefromjpeg($spa th);
      >
      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.

      Comment

      Working...