tags:

views:

71

answers:

4

Hello,

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

+6  A: 

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
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
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
And we even have the scream extention now, which disables the @.... go figure.
Wrikken
A: 

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

STW
+3  A: 

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

Michael Borgwardt
A: 

but it can reduce your code performance

manoelhc