@在PHP中是什么意思? [英] What does @ mean in PHP?
问题描述
可能重复:
参考-此符号在PHP中是什么意思? >
Possible Duplicate:
Reference - What does this symbol mean in PHP?
我想知道@
在PHP语言中的含义.我见过有人在使用
I was wondering what @
means in PHP language. I have seen people using
$connect = @mysql_query('sql query here');
不知道为什么.有人可以帮我解释一下吗?
Not sure why. Could someone explain it for me?
推荐答案
@
运算符告诉PHP禁止显示错误消息,这样就不会显示错误消息.
The @
operator tells PHP to suppress error messages, so that they will not be shown.
例如,使用:
$result = mysql_query("this is an invalid query");
会导致显示警告,告诉您MySQL查询无效,而
would result in a warning being shown, telling you that the MySQL query is invalid, while
$result = @mysql_query("this is still an invalid query");
不会.
但是,请注意,这是非常糟糕的编程习惯,因为它不会使错误消失,而只是将它们隐藏起来,并且使调试变得更加糟糕,因为您看不到代码的实际问题.
Note, however, that this is very bad programming practice as it does not make error disappear, it just hides them, and it makes debugging a heck of a lot worse since you can't see what's actually wrong with your code.
您应该禁用@
,而仅display_errors
禁用 /errorfunc.configuration.php"rel =" noreferrer> php.ini error_reporting
和display_errors
Instead of using @
, you should disable just error_reporting
and display_errors
display_errors
in php.ini
这篇关于@在PHP中是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!