Suppress error with @ operator in PHP
Posted
by Mez
on Stack Overflow
See other posts from Stack Overflow
or by Mez
Published on 2008-09-25T23:37:41Z
Indexed on
2010/04/26
23:23 UTC
Read the original article
Hit count: 192
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?
© Stack Overflow or respective owner