为什么在 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
Why use @ before variable in PHP?
提问by shaz
Possible Duplicate:
What is the use of the @ symbol in PHP?
Reference — What does this symbol mean in 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
回答by Phil
The only reason I can think of to use the error suppression operator before a variable would be to suppress E_NOTICE
errors 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
如果您想避免通知和警告,请在变量前使用 @ 符号