在PHP中,L值前面的'at'符号是什么意思? [重复]
This question already has an answer here:
Everything I can find refers to the use of the @
symbol as a prefix to an expression, e.g.:
$foo = @bar();
This is not what I'm talking about here. I have a statement which uses the @
symbol as a prefix to an L-value, like:
@$foo = bar();
What does this mean?
(Ideally, please explain the semantics as a de-sugaring of this statement into one that does not use the @
symbol.)
</div>
此问题已经存在 这里有一个答案: p>
-
参考 - 这个符号在PHP中意味着什么?
18 answers
\ n span>
li>
ul>
div>
我能找到的一切都是指使用
@ code>符号作为表达式 em>的前缀,例如: p>
$ foo = @bar(); code>
这是不 em>我在这里谈论的内容。 我有一个声明,它使用
@ code>符号作为L值的前缀,如: p>
@ $ foo = bar(); \ n code> pre>
这是什么意思? p>
(理想情况下,请将语义解释为将此语句解压为一个语句 不使用
@ code>符号。) p> div>
@
symbol is used to suppress error messages
PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
For example;
The following code doesn't produce any errors on screen;
<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
@$foo = $bar;
echo $foo;
However, without the @
it does;
Notice: Undefined variable: bar in C:\xampp\htdocs\test\test.php on line 6