1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

What does = @$variable do?

Discussion in 'General PHP and MySQL Discussions' started by Marcus, Aug 13, 2013.

  1. Marcus

    Marcus Well-Known Member

    I am curious what "@" is doing in this declaration:
    $variable = (string)@$this->_params['posts'][@$postId]['setting']
  2. Jeremy

    Jeremy XenForo Moderator Staff Member

    The @ symbol when used in PHP will hide any errors or warnings that occur because of that specific statement.
    Marcus likes this.
  3. Terry Harvey

    Terry Harvey Member

    What King Kovifor said. Although it's generally considered bad practice.
    Adam Howard and rellek like this.
  4. rellek

    rellek Well-Known Member

    However, it's the easiest way to make old (or crappy) software like Joomla 1.x work without raising errors in PHP 5.3+.

    Btw @Marcus, where did you get this line from?
  5. twhiting9275

    twhiting9275 Active Member

    actually, the easiest way is to use ini to set display_errors to 0 , but yeah, for most that's going to be the easiest way :)
  6. Chris D

    Chris D XenForo Developer Staff Member

    I think it has valid usage.

    XenForo uses it in a few places.
    twhiting9275 likes this.

Share This Page