- set_exception_handler: documentation ( source)
- set_error_handler: documentation ( source)
<?php
class ExceptionHandler
{
public function __construct()
{
set_exception_handler($this);
}
public function __invoke(Exception $e)
{
echo $exception->getMessage();
}
}
function error($no, $message)
{
throw new Exception($message);
}
set_error_handler('error');
new ExceptionHandler;
throw new Exception("Test");