1.2.10. @ Operator¶
@ is the ‘no scream’ operator : it suppresses error output.
This operator is very slow : it processes the error, and finally decides not to display it. It is often faster to check the conditions first, then run the method without @
.
You may also set display_error to 0 in the php.ini
: this avoids user’s error display, and keeps the error in the PHP logs, for later processing.
The only situation where @
is useful is when a native PHP function displays errors messages and there is no way to check it from the code beforehand.
This was the case with fopen(), stream_socket_server(), token_get_all(). As of PHP 7.0, they are all hiding errors when @
is active.
<?php
// Set x with incoming value, or else null.
$x = @$_GET['x'];
?>
Name |
Default |
Type |
Description |
authorizedFunctions |
noscream_functions.json |
data |
Functions that are authorized to sports a @. |
See also I scream, you scream, we all scream for @, Error Control Operators and Five reasons why the shut-op operator should be avoided.
1.2.10.1. Connex PHP features¶
1.2.10.1.1. Suggestions¶
Remove the @ operator by default
1.2.10.1.2. Specs¶
Short name |
Structures/Noscream |
Rulesets |
All, Analyze, Appinfo, CE, CI-checks, Changed Behavior, Performances |
Exakat since |
0.8.4 |
PHP Version |
All |
Severity |
Minor |
Time To Fix |
Quick (30 mins) |
Precision |
Very high |
ClearPHP |
|
Examples |
|
Available in |