note 64522 deleted from function.set-error-handler by bjori

From: Date: Mon, 17 Apr 2006 17:00:38 +0000
Subject: note 64522 deleted from function.set-error-handler by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-108353@lists.php.net to get a copy of this message
Note Submitter: docey Reason: in docs ---- making use of a class based errorhandler is much better as it allows you to store filepointers inside the class or keep a record of error wich have been handled since in an array. but the problem is that php support class based error handlers since php4.3 but here's a very simple workaround that works in all version of php. <?php function myerrorhandler($errno, $errstr, $errfile, $errline, errcontext){ static $cp; // this is where we store the class //check to see if cp already contains our class. if((is_object($cp)) AND (get_class($cp) == "myclass")){ }else{ // class does not alreay exists so create it. $cp = new myclass(); } // then call our class based error handler return $cp->handler($errno, $errstr, $errfile, $errline, $errcontext); } ?> now register your errorhandler like this: set_errorhandler("myerrorhandler"); wich is the same as: set_errorhandler(array($myclass, "handler")); and this simple workaround works in all php versions.

« previous php.notes (#108353) next »