How does php limit the execution time of a function?
Source: Internet
Author: User
How does php limit the execution time of a function ??? For example, you have defined a function that runs for a period of time ranging from 1 second to 60 seconds. This function is used now, but one problem is that the time cannot be greater than 30 seconds. if the value is greater than 30 seconds, the program reports an error. Is there any way to do this without modifying the original function, to limit the running time of the original function. if you want to run the function for more than 30 seconds, a result is returned no matter whether the function is successful or not ., How does php limit the execution time of a function ???
For example, you have defined a function that runs for a period of time ranging from 1 second to 60 seconds. This function is used now, but one problem is that the time cannot be greater than 30 seconds. if the time is greater than 30 seconds, the program reports an error,
There is no way to limit the running time of the original function without modifying the original function. if you run the function for more than 30 seconds, a result is returned regardless of whether the function is successful or not.
------ Solution --------------------
It looks like no. you can use it. try it.
1. set_time_limit
2. fsockopen
3. curl
------ Solution --------------------
"Without modifying the original function, a result is returned no matter whether the function is successful or not. "
I don't think it is possible. of course, unless you modify the internal implementation of php...
------ Solution --------------------
I personally think it is unlikely. Even if you define a time jump, the function should be executed continuously.
------ Solution --------------------
Php runs from top to bottom and records a time at the end of a time function at the beginning of the function. you should be able to know the execution time of this function.
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