note 37857 added to language.operators.errorcontrol

From: Date: Sun, 30 Nov 2003 09:26:37 +0000
Subject: note 37857 added to language.operators.errorcontrol
Groups: php.notes 
Request: Send a blank email to php-notes+get-61158@lists.php.net to get a copy of this message
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 ... } ---- Manual Page -- http://www.php.net/manual/en/language.operators.errorcontrol.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37857 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37857&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37857&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#61158) next »