Voting

: eight minus zero?
(Example: nine)

The Note You're Voting On

bohwaz
14 years ago
If you use the ErrorException exception to have a unified error management, I'll advise you to test against error_reporting in the error handler, not in the exception handler as you might encounter some headaches like blank pages as error_reporting might not be transmitted to exception handler.

So instead of :

<?php

function exception_error_handler($errno, $errstr, $errfile, $errline )
{
throw new
ErrorException($errstr, 0, $errno, $errfile, $errline);
}

set_error_handler("exception_error_handler");

function
catchException($e)
{
if (
error_reporting() === 0)
{
return;
}

// Do some stuff
}

set_exception_handler('catchException');

?>

It would be better to do :

<?php

function exception_error_handler($errno, $errstr, $errfile, $errline )
{
if (
error_reporting() === 0)
{
return;
}

throw new
ErrorException($errstr, 0, $errno, $errfile, $errline);
}

set_error_handler("exception_error_handler");

function
catchException($e)
{
// Do some stuff
}

set_exception_handler('catchException');

?>

<< Back to user notes page

To Top