Collecting all PHP Errors as Exception

If you want to collect all PHP errors (except the FATAL errors) as exception, you can use the following code:

<?php
function exception_handler($severity, $message, $filename, $lineno)
{
throw new ErrorException($message,0,$severity,$filename,$lineno);
}
set_exception_handler(‘exception_handler’);
?>

Advertisements