When is the '@' operator used in PHP and MySQL

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.


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


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.

链接地址: http://www.djcxy.com/p/57700.html

上一篇: 什么是php @标志

下一篇: 什么时候在PHP和MySQL中使用'@'运算符