PHP 8.3.21 Released!

Voting

: min(one, two)?
(Example: nine)

The Note You're Voting On

sean at seanodonnell dot com
19 years ago
Using the 'set_exception_handler' function within a class, the defined 'exception_handler' method must be declared as 'public' (preferrable 'public static' if you use the "array('example', 'exception_handler')" syntax).

<?php
class example {
public function
__construct() {
@
set_exception_handler(array('example', 'exception_handler'));
throw new
Exception('DOH!!');
}

public static function
exception_handler($exception) {
print
"Exception Caught: ". $exception->getMessage() ."\n";
}
}

$example = new example;

echo
"Not Executed\n";
?>

Declaring the 'exception_handler' function as 'private' causes a FATAL ERROR.

[derick: red. updated statement about static a bit]

<< Back to user notes page

To Top