Description
Both Error and Exception are handled by set_exception_handler() where the naming imply only the Exception.
A better explicit and intuitive name is set_throwable_handler().
I was not expecting the handler to be triggered by an Error and cancelling the default PHP behavior.
PS: not talking about E_XXX errors, but Error that implements Throwable
The following code:
<?php
function handler(){
echo "Exception Handler";
}
set_exception_handler('handler');
new MyClass();
Resulted in this output:
But I expected this output instead:
Fatal error: Uncaught Error: Class "MyClass" not found in /home/user/scripts/code.php:7
Stack trace:
#0 {main}
thrown in /home/user/scripts/code.php on line 7
PHP Version
8.*
Operating System
No response