Suppress error with @ operator in PHP
- by Mez
In your opinion, is it ever valid to use the @ operator to suppress an error/warning in PHP whereas you may be handling the error?
If so, in what circumstances would you use this?
Code examples are welcome.
Edit: Note to repliers. I'm not looking to turn error reporting off, but, for example, common practice is to use
@fopen($file);
and then check afterwards... but you can get rid of the @ by doing
if (file_exists($file))
{
fopen($file);
}
else
{
die('File not found');
}
or similar.
I guess the question is - is there anywhere that @ HAS to be used to supress an error, that CANNOT be handled in any other manner?