@ is the
Error control operator in PHP.
When prefixed to an expression, any error/warning messages that might be generated by that expression will be
ignored.
i.e. It suppresses error/warning messages.
Example 1:
<?php
echo 2/0; //Gives warning : Division by zero
echo @(2/0); echo 2/0; //@ suppresses the warning
}
?>
Output
Warning: Division by zero in I:\xampp\htdocs\xampp\Tutorials\ComparisonOpearatorsExample.php
on line 3
In the above example, we do not get the warning "Division by zero" when we add Error Control operator before the expression 2/0.
Example 2:
<?php
method(); //Gives Fatal Error : Call to undefined function methodCall()
echo @(2/0); echo 2/0; //@ suppresses the Fatal error
}
?>
Output
Fatal error: Call to undefined function methodCall() in
I:\xampp\htdocs\xampp\Tutorials\ComparisonOpearatorsExample.php on line 5
In the above example we are calling a function which has not been defined, that a fatal error is thrown.
But when the function call is prefixed by @ operator, the fatal error is not displayed.