According to the PHP Manual : PHP's internal functions mainly use error reporting, but only modern object-oriented extensions use exceptions. However, errors can simply be thrown to exceptions with an ErrorException
Example provided in ErrorException:
<?php function exception_error_handler($errno, $errstr, $errfile, $errline ) { throw new ErrorException($errstr, 0, $errno, $errfile, $errline); } set_error_handler("exception_error_handler");
It seems to allow using Exceptions instead of default error reporting. My question is, is this an encouragement or just a choice for us?
Also, what is the best practice, use the exception yourself, as in the above example, or use both the exception (set_exception_handler) and the error report (set_error_handler) next to each other?
source share