note 30230 deleted from function.set-error-handler by cmb
| From: | cmb@php.net | Date: | Sun, 25 Aug 2019 08:55:47 +0000 |
| Subject: | note 30230 deleted from function.set-error-handler by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-211985@lists.php.net to get a copy of this message | ||
Note Submitter: bob at db dot org
----
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>';
}
}
?>