Is set_exception_handler meant to replace set_error_handler?
php
Solution
Short answer: No. That are two different functions.
Long answer: It's not meant to replace but to make use of. `set_exception_handler`Docs is used for exceptions and `set_error_handler`Docs for errors. That are two different pair of shoes.
See as well:
- PHP: exceptions vs errors?
- PHP: What is the flow of control for error handling?
- Error Handling and LoggingDocs
Problem
According the PHP Manual: Internal PHP functions mainly use Error reporting, only modern Object oriented extensions use exceptions. However, errors can be simply translated to exceptions with ErrorException The 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 the default error reporting. My question is, is this an encouragement or merely an option for us? Moreover, which is a better practice, use Exception alone like the above example, or use both Exception (set_exception_handler) and Error reporting (set_error_handler) alongside with each other?