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.)
@
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