I think @ is fine to suppress warnings / notices which would otherwise take down my app.
I use a custom error handler which aborts the page when any enabled error occurs, INCLUDING warning, notice, etc. This is very helpful as it ensures that my pages never charge headlong into oblivion.
As far as I'm concerned, NORMALLY, even an E_NOTICE is a bad thing.
However, occasionally I don't mind - the commonest is assigning something from a checkbox:
$blah = (bool) $_POST['checkbox'];
Which of course, would generate an E_NOTICE if the checkbox was not checked, due to nonexistent array element. So I do
$blah = (bool) @ $_POST['checkbox'];
Instead, safe in the knowledge that the @ will never be suppressing any important error, as that's pretty much the only thing which can fail.
It is a major problem using @ to do anything significant, e.g.
$f = @some_special_extension_function();
if ($f === FALSE) { // error handling ...
}
Sounds fine, until you realise that if the extension function was absent, a "Call to undefined function" fatal error will occur, but the @ will suppress it, resulting in a totally useless "blank page" problem which would prove difficult to diagnose.
Conclusion:
- Using @ to suppress notices / warnings in an expression is OK.
- Using @ when calling functions is bad.
Mark