#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    3
    Rep Power
    0

    @ (at symbol) suppresses error log reporting too?


    I'm trying to figure out if I can get any error reporting from something being suppressed by the @ symbol, but I haven't found anything that shows the error anywhere by default. I read I can set things up to report it somewhere, but are the suppressed errors by default logged somewhere? They weren't showing in the server logs. Is there something similar I can use so that output is suppressed but still logged?
  2. #2
  3. Wiser? Not exactly.
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2001
    Location
    Bonita Springs, FL
    Posts
    5,953
    Rep Power
    4033
    The @ operator essentially sets the error_reporting level to 0 for the duration of the statement it is applied to. PHP's default error handlers will check the error_reporting level to see if the error needs to be reported prior to echoing/logging it anywhere so @ prevents any echoing/logging.

    There are a couple ways around it. First you can install your own error handler ([phpnet=set_error_handler]set_error_handler[/phpnet]) as PHP will still call the error handler functions even when @ is used. Inside your error handler you can log the error somewhere yourself.

    Second, you can setup the scream extension and enable it. That will cause @ to be ignored essentially causing all errors to be reported.
    Recycle your old CD's, don't just trash them



    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    the best solution probably is to remove the "@" completely. This is generally a terrible way of error handling. If you see a lot of "@", it's a good indicator of crappy code waiting to be fixed (if possible, of course).

    The terrible thing about "@" is that it will swallow any error, no matter how bad it is. Even if there's a typo in the expression so that it cannot possibly work, the "@" operator will make sure you never get a notice about it -- happy debugging.
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".

IMN logo majestic logo threadwatch logo seochat tools logo