PHP ignore_user_abort () function set and client disconnect script continue execution
Ignore_user_abort () can be implemented when the client shuts down can still execute PHP code, can keep the PHP process has been executing, can achieve so-called scheduled task function and continuous process, only need to open the execution script, unless the Apache and other server restart or have script output, This PHP script will always be in the state of execution, but at the cost of a PHP execution of the script's ongoing process, the cost is large, but can achieve a lot of unexpected features.
Definition and usage
The Ignore_user_abort () function sets the execution of the script to terminate if the client disconnects.
This function returns the previous value of the User-abort setting (a Boolean value).
Grammar
Ignore_user_abort (setting)
Parameter description
setting is optional. If set to true, disconnecting from the user is ignored and setting to false causes the script to stop running. If this parameter is not set, the current setting is returned.
Note : PHP does not detect whether a user has been disconnected until an attempt is made to send a message to the client. Simply use the ECHO statement to not ensure that information is sent, see the flush () function.
Examples of Use :
(1) Implement a cyclic script execution task with Set_time_limit () function
(2) Customizing the implementation file output and tracking the execution results of the ignore_user_abort () function
Opens the phpernote.com.php file with the following file contents:
Current time:1273735029 Stop:9
The principle is that even if the client terminates the script, it is still executed every 10 seconds and prints out the current time and end point, so that the Ignore_user_abort () function can be tested.
It is also very practical to use the Ignore_user_abort () function to realize the business of planning tasks, continuous processes, and so on.
Articles you may be interested in
- thinkphp page Jump (successerror) How to set the jump wait time
- PHP window Platform Simulation CHECKDNSRR function detects if email is real
- Php method for verifying mailboxes, URLs, and IP addresses using the filter function
- jquery waits for Ajax to finish before continuing with the effect of the following code:
- function and usage of PHP get_headers functions
- Use PHP function memory_get_usage to get the current PHP memory consumption to achieve program performance optimization
- PHP using ziparchive function to realize the compression and decompression of files
- How PHP determines whether the current operating system is Linux or Windows
http://www.bkjia.com/PHPjc/1008339.html www.bkjia.com true http://www.bkjia.com/PHPjc/1008339.html techarticle php ignore_user_abort () function set with client disconnect script continue execution Ignore_user_abort () can be implemented when the client shuts down still can execute PHP code, can keep PHP process always in ...