- version_compare: documentation ( source)
- set_exception_handler: documentation ( source)
- restore_exception_handler: documentation ( source)
<?php
function cExceptionHandler($exception)
{
if ($exception instanceof c_Exception_Exit) {
$msg = $exception->getMessage();
if ($msg) {
echo $msg;
}
exit();
} elseif ($exception instanceof c_Exception_Fatal) {
die($exception->getMessage());
}
restore_exception_handler();
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
$class = get_class($exception);
throw new $class($exception->getMessage(), $exception->getCode(), $exception);
}
throw $exception;
}
set_exception_handler('cExceptionHandler');
throw new Exception('test');