Why didn't I execute my error handling code? PHPcode & lt ;? Php defines the Error_Handler function *** @ param $ error_level error level ** @ param $ error_message error message ** @ param $ file error file * for help why didn't I execute my error handling code?
PHP code
The above code calls the undefined function myerror_method (); I should execute the custom error handler error_handler ().
Echo "11111111111"; this sentence has not been executed. please help me read it. thank you!
------ Solution --------------------
You call a function that does not exist. this is a fatal error that causes the script to end.
You can try echo $ sakdfhgkjad; if the variable does not exist, you can call the custom error processing function normally.
BTW:
If you have to call the register_shutdown_function in case of a fatal error, try the register_shutdown_function.
------ Solution --------------------
Php programs are executed in two phases.
1. Pre-compilation stage: completes the syntax analysis of program files and generates intermediate code
2. execution stage: run intermediate code
Set_error_handler ("error_handler ");
It is executed in the execution phase.
So it cannot handle errors in the pre-compilation phase
------ Solution --------------------
Discussion
Php programs are executed in two phases.
1. Pre-compilation stage: completes the syntax analysis of program files and generates intermediate code
2. execution stage: run intermediate code
Set_error_handler ("error_handler ");
It is executed in the execution phase.
So it cannot handle errors in the pre-compilation phase