note 30230 added to function.set-error-handler
| From: | bob at db dot org | Date: | Tue, 11 Mar 2003 19:09:54 +0000 |
| Subject: | note 30230 added to function.set-error-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45107@lists.php.net to get a copy of this message | ||
The documentation on this page kindly offers the following on using (class) methods as error
handlers:
Note: Instead of a function name, an array containing an object reference and a method name can
also be supplied. (Since PHP 4.3.0)
Since that's all it says about the subject, I thought I'd offer a sample implementation to
show how this can be used:
<?php
class error {
var $conf;
var $lang;
function error($conf, $lang) {
$this->conf = $conf;
$this->lang = $lang;
set_error_handler(array(&$this, 'handler'));
}
function handler($no, $str, $file, $line, $ctx) {
echo '<pre>';
echo 'no : ' . $no . "\n";
echo 'str : ' . $str . "\n";
echo 'file : ' . $file . "\n";
echo 'line : ' . $line . "\n";
echo 'ctx : ';
print_r($ctx);
echo '</pre>';
}
}
?>
--
http://www.php.net/manual/en/function.set-error-handler.php
http://master.php.net/manage/user-notes.php?action=edit+30230
http://master.php.net/manage/user-notes.php?action=delete+30230
http://master.php.net/manage/user-notes.php?action=reject+30230