note 37857 deleted from language.operators.errorcontrol by tularis
| From: | tularis@php.net | Date: | Tue, 12 Aug 2008 16:38:10 +0000 |
| Subject: | note 37857 deleted from language.operators.errorcontrol by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143410@lists.php.net to get a copy of this message | ||
Note Submitter: sdavey at datalink dot net dot au
----
To suppress error warnings for functions that use the error operator '@' in your own error
handlers, I found a sentence on the set_error_handler() page that explains it:
http://www.php.net/manual/en/function.set-error-handler.php
To paraphrase, it says that PHP temporarily sets the value of error_reporting() to 0 when in the
error handler.
So, if you have the following:
$fp = @fopen("non-existent-file", "r");
when your custom error handler function is called, you can check the value of error_reporting() like
this:
function handler($type, $str, $file, $line, $info) {
// don't respond to the error if it
// was suppressed with a '@'
if (error_reporting() == 0) return;
// otherwise, handle the error
...
}