-3

Hey Stackoverflow community. I had some issues with my code yesterday and somehow solved it by adding @ in front of some of my statements such as this

 if (@!empty($_SESSION["customer]) {
   //code
}

I had never seen it before but it worked perfectly. I have searched for it on Google but i can't find any useful description about the @ in PHP. I want to hear if anyone knows what it does, how it works and mean in PHP. Thanks!

PIK123
  • 11
  • 1
  • 3

1 Answers1

1

The @ surpresses warning and error messages.

For example, if you run the command is_file("text.txt") and text.txt does not exist, you get a warning message. If you run @is_file("text.txt") you won't get this warning message.

Sushant Pimple
  • 1,337
  • 1
  • 13
  • 26
  • 1
    Note that you should avoid using the @ operator, since it will make debugging your code much harder. In the example posted above, the offending code should be wrapped with a "file_exists()" statement. – Erik Baars Jan 22 '18 at 09:21