SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot ameerulislam's Avatar
    Join Date
    Jul 2011
    Posts
    145
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    what does this @ do?

    PHP Code:
    <?php if(@$isLogin and $userinfo->role == "user"): ?>
    what does @$isLogin mean here?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,164
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    @ is used to suppress error warnings, as far as I know. Prolly means it should be coded better.

  3. #3
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,014
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    It's probably been placed there in-case the the $isLogin has not been "set". You can check to see if a variable is "set" using isset() .
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  4. #4
    SitePoint Addict bronze trophy
    Join Date
    Apr 2013
    Location
    Ithaca
    Posts
    351
    Mentioned
    6 Post(s)
    Tagged
    1 Thread(s)
    to suppress warning messages, it is a bad programming practice but can be useful for legacy code, especially if it comes from third party that you have no idea or interest in refactoring/fixing. For me though, I run a VB3.8 forum that I end up using lots of @ operator to suppress warning messages generated due to PHP version compatibility. *sigh*

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2005
    Location
    Michigan, USA
    Posts
    434
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I've never seen it used to check a boolean like that. Better would be
    PHP Code:
    if( isset( $isLogin ) && $isLogin 
    Using error suppression increases overhead (slows the script a little) and makes it harder to debug. It can be useful sometimes but for cases like that, no way.
    - Robert

  6. #6
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,139
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)
    I agree. Using error suppression is usually a sign of poor coding. Even if you can't use native functions it seems to me one could usually use some error/exception handling to log unexpected errors that might happen and are beyond your control.

    I once submitted a ticket to WordPress listing all the places that I knew of where error suppression was used in the Core files, and even gave fixes for several.
    Waste of time, too busy adding features and chasing down security bugs I guess.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •