LonghornPHP 2026

Voting

: five minus four?
(Example: nine)

The Note You're Voting On

Glen
19 years ago
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.

<< Back to user notes page

To Top