Hi,
Great answers have already been given, about the @ operator, but here's a couple of more informations that could be useful, either to you or someone else :
- If, for debugging purposes, you need the disable the
@ operator
, you can install the scream extension -- see also the manual -- which is really useful when you're maintaining some kind of old application not well designed / coded ^^
- Depending on your PHP configuation (if the
track_errors
option is activated), you might be able to use $php_errormsg
to get the last error message.
Considering this piece of code :
// This file doesn't exist
if (!@fopen('/tmp/non-existant-file.txt', 'r')) {
var_dump($php_errormsg);
}
// My Apache server doesn't have the right to read this file
if (!@fopen('/tmp/vboxdrv-Module.symvers', 'w')) {
var_dump($php_errormsg);
}
You would get this :
string 'fopen(/tmp/non-existant-file.txt) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory' (length=129)
string 'fopen(/tmp/vboxdrv-Module.symvers) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: Permission denied' (length=122)
So, real, useful, meaningful, error messages ;-)