Search code examples
phpexceptionerror-reporting

Tuning PHP exception reporting similar to error reporting


For Apache web server, we can tune the error reporting via error_reporting entry in php.ini.

Is there a similar setting for exception reporting?

My below code show that error_reporting doesn't effect exception throw command.

function actionTestThrow() {
    error_reporting(null);
    $i=122;        
    throw new Exception('abb');
    $i=344;        
    echo $i;
}

Solution

  • Exceptions are always fatal. You can't just hide them. If you want to ignore an exception, you'll need to handle it in a try catch block.


    What you can do, is extend the exception class (FatalException, NoticeException) etc, and handle each differently, more on that on Extending Exceptions