为什么在 PHP 中使用 @before 变量?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4151418/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 12:07:32  来源:igfitidea点击:

Why use @ before variable in PHP?

php

提问by shaz

Possible Duplicate:
What is the use of the @ symbol in PHP?
Reference — What does this symbol mean in PHP?

可能的重复:
PHP 中@ 符号的用途是什么?
参考——这个符号在 PHP 中是什么意思?

what does using <?php echo @$fnameerror; ?>mean. why use @ before variable in php

使用<?php echo @$fnameerror; ?>是什么 意思。为什么在 php 变量之前使用@

回答by Scott Evernden

error control operator.. suppresses error messages ..

错误控制运算符.. 抑制错误消息 ..

回答by GWW

@ is pure evil. It's not a good idea to use. You can find an explanation about it here.

@是纯粹的邪恶。使用它不是一个好主意。您可以在此处找到有关它的解释。

It can cause massive debugging headaches because it will even suppress critical errors.

它可能会导致大量调试问题,因为它甚至会抑制严重错误。

回答by Phil

The only reason I can think of to use the error suppression operator before a variable would be to suppress E_NOTICEerrors if the variable is undefined.

我能想到的在变量之前使用错误抑制运算符的唯一原因E_NOTICE是在变量未定义时抑制错误。

As others have mentioned, this is a bad idea. It's much better to actually deal with errors than ignore them.

正如其他人所提到的,这是一个坏主意。实际处理错误比忽略它们要好得多。

回答by JuLy

It's used to avoid the error notice.

它用于避免错误通知。

回答by Conex

If you want to avoid notices and warnings use @ sign before variable

如果您想避免通知和警告,请在变量前使用 @ 符号