Error Suppression¶
Error suppression in PHP is achieved with the @ operator placed before an expression. It silences any error, warning, or notice that expression might produce.
Using @ is widely considered bad practice: it hides bugs, degrades performance, and makes debugging harder. Better alternatives include proper validation, try/catch blocks, or a custom error handler.
The scream extension and scream.enabled ini directive can disable the @ operator entirely.
<?php
// Bad practice: silences errors
$result = @file_get_contents('missing.txt');
// Better: check first
if (file_exists('missing.txt')) {
$result = file_get_contents('missing.txt');
}
?>
See also Error suppression operator.
Related : Error, @, No Scream Operator, Error Handling, Operators, Error Reporting, Appeasement Pattern, SplSubject