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

One thought on “Collecting all PHP Errors as Exception

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s