note 73607 added to function.set-exception-handler
| From: | Glen at osu1 dot php dot net | Date: | Sat, 03 Mar 2007 08:34:23 +0000 |
| Subject: | note 73607 added to function.set-exception-handler | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124038@lists.php.net to get a copy of this message | ||
If you want a class instance to handle the exception, this is how you do it :
<?php
class example {
public function __construct() {
@set_exception_handler(array($this, 'exception_handler'));
throw new Exception('DOH!!');
}
public function exception_handler($exception) {
print "Exception Caught: ". $exception->getMessage() ."\n";
}
}
$example = new example;
?>
See the first post (Sean's) for a static example. As Sean points out, the exception_handler
function must be declared public.
----
Server IP: 69.147.83.197
Probable Submitter: 67.124.149.32
----
Manual Page -- http://www.php.net/manual/en/function.set-exception-handler.php
Edit -- https://master.php.net/note/edit/73607
Del: integrated -- https://master.php.net/note/delete/73607/integrated
Del: useless -- https://master.php.net/note/delete/73607/useless
Del: bad code -- https://master.php.net/note/delete/73607/bad+code
Del: spam -- https://master.php.net/note/delete/73607/spam
Del: non-english -- https://master.php.net/note/delete/73607/non-english
Del: in docs -- https://master.php.net/note/delete/73607/in+docs
Del: other reasons-- https://master.php.net/note/delete/73607
Reject -- https://master.php.net/note/reject/73607
Search -- https://master.php.net/manage/user-notes.php