I was wondering what the use cases are to use the @ symbol in PHP to suppress errors for an expression.
It is discouraged by a lot of people for good reasons but I was wondering when it actually can help to write cleaner code. I came across the following example where the validation of the object is done inside and outside the function. Validation done inside the function can sometimes mean you can keep your code outside of the function cleaner.
Validation outside the function:
if (isset($object)) {
a($object);
}
function a($object) {
}
Validation inside the function with use of @:
a(@$object);
function a($object) {
if (!isset($object)) {
return false;
}
}
Are there any good use cases for the @ symbol?