- set_exception_handler: documentation ( source)
- set_error_handler: documentation ( source)
<?php
set_error_handler(function($num, $msg, $file, $line)
{
throw new ErrorException($msg, 0, $num, $file, $line);
});
set_exception_handler(function($e)
{
echo '** Uncaught Exception **'.PHP_EOL;
echo (string)toString();
});
try
{
// Will be caught
echo array().PHP_EOL;
}
catch(ErrorException $e) {}
// Will not be caught
echo array().PHP_EOL;