1

Possible Duplicate:
What is the use of @ symbol in php?
PHP functions and @functions
What does the “@” symbol do in SQL?

Often when looking through online resources / questions including code on this website, I often come across the '@' operator.

In the PHP code I see, the @ operator generally comes before a method such as @fread(). However, by the looks of the code, it wouldn't have actually made a difference whether or not fread() was called with or without the '@' in front of the method.

In the MySQL code, the @ operator generally comes before a column/field name. I believe that the @ is used to access a default variable instantiated at some point manually by the user, alike to an env variable in PHP.

Please can you tell me if my assumptions are correct, and if not, when and why the '@' sign or operator should in fact be used?

Thanks,

Max.

Community
  • 1
  • 1
max_
  • 22,619
  • 38
  • 116
  • 207

2 Answers2

10

In PHP it means suppress any notices/warnings raised by this function eg mail() will throw an error when it fails to send. You can do

$Success = @mail(...)

To suppress the error and handle success/failure yourself. See the Error Control Operator page for more information.

In MySQL, @ is used to prefix user-defined variables

Tremmors
  • 2,778
  • 14
  • 13
Basic
  • 25,223
  • 23
  • 108
  • 188
1

In PHP the at sign (@) denotes that any error messages that might be generated by that expression will be ignored.

In MySQL the @ before a name denotes a local, user-defined variable.

Mithrandir
  • 22,998
  • 5
  • 41
  • 61