I describe a class - an error handler. Some of his methods are:
public function __construct() { if (DEBUG) { error_reporting(-1); ini_set('display_errors', true); } else { error_reporting(0); ini_set('display_errors', false); } set_error_handler([$this, 'errorHandler']); set_exception_handler([$this, 'exceptionHandler']); register_shutdown_function([$this, 'fatalErrorHandler']); } public function errorHandler($code, $message, $file, $line) { echo '<br />' . __METHOD__ . '<br />'; // some code die; } public function fatalErrorHandler() { echo '<br />' . __METHOD__ . '<br />'; // some code die; } public function exceptionHandler(\Throwable $e) { echo '<br />' . __METHOD__ . '<br />'; // some code die; } The logic is as follows: at the beginning of the application, an instance of this object is created and stored in the static property of the main object of the application, which lives all the time. As you can see, error handlers and exceptions are initialized in the object's constructor.
The problem is this: fatal errors, such as Parse error, are not caught by my handler. What is the problem?
parse error. - teranregister_shutdown_functionmay seem to be . - user207618php.ini, which includes the code with registering the handler before executing the scripts themselves. - user207618