Example of using PHP function register_shutdown_function

Source: Internet
Author: User

In some cases, we need to do some follow-up work at the end of the program execution, and this time, PHP's register_shutdown_function function will help us to implement this function.
Introduction to Functions
When the PHP program executes, the Register_shutdown_function function is automatically executed, and the function requires a parameter that specifies who will handle the subsequent work. Among them, the execution of the program is completed, divided into the following situations:
First: An error occurred during the execution of the PHP code
The second type: PHP code successfully executed
Third: PHP code runs out of time
Fourth type: page is forced to stop by the user

Program Entry File Introduction

register_shutdown_function (array(' Error ', ' systemerror '));

Error class source code

<?PHPclasserror{ Public Static functionSystemerror () {$message= ' '; if($error=Error_get_last ()) {            $separator= "\ r \ n"; $date=Date(' Y-m-d h:i:s ', Time()); $message.= "[".$date."] ---message: ".$error[' Message '].$separator; $message. = "File:".$error[' File '].$separator; $message. = "line:".$error[' Line '].$separator; $url= ' '; $data=Array(                ' Info ' =$message, ' type ' = ' BBS '            ); Helper:: Curlrequest ($url,$data,true, 5); }Else{            //Some other business logic is handled here        }    }}

Example of using PHP function register_shutdown_function

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.