2

I'm working through some PHP code and cannot figure out what the significance of the @ sign is in this code:

    $data = @fread($_socket, 8192);

I wasn't able to find many other examples on php.net either that explain what @ does, instead it is just used.

Thanks

sholsapp
  • 15,542
  • 10
  • 50
  • 67

3 Answers3

6

The @ suppress the error message that would occur if what is on the right-hand of the @ were to fail.

Here's the link to the php.net page that has full details http://php.net/manual/en/language.operators.errorcontrol.php

dalton
  • 3,656
  • 1
  • 25
  • 25
  • 3
    And it's also the cause of the White Screen of Death (where no error messages are shown or logged, yet the script aborts)... – ircmaxell Jul 15 '10 at 21:58
  • It's also a very minor performance hit. The bytecode compiler has to go out of the way to turn off error reporting just for that one statement, then turn it on again. Avoid it! – Charles Jul 15 '10 at 22:00
3

That's the error control operator, which suppresses error messages.

Michael Borgwardt
  • 342,105
  • 78
  • 482
  • 720
0

it's used as a directive to suppress error messages from the call

STW
  • 44,917
  • 17
  • 105
  • 161