How can I avoid executing my exception handling code?

Source: Internet
Author: User
Why didn't I execute my error handling code? PHPcode & lt ;? Php // define the Error_Handler function/*** define the Error_Handler function *** @ param $ error_level error level ** @ param $ error_mess help me see why I didn't execute my error handling code ah
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.