PHP page function to set the time-out limit method, PHP page function timeout
This article describes the method of setting the timeout limit for PHP page functions. Share to everyone for your reference. Here's how:
Encounter the page program execution timeout will remind fatal Error:maximum execution time of the seconds exceeded is because the program executes more than the maximum allowable execution time, the solution we summed up a few for everyone to choose.
For functions we can use the following method, directly to the function set timeout time to operate, the code is as follows:
Copy the Code code as follows: Declare (ticks = 1);
function A () {
Sleep (10);
echo "a Finishi";
}
Function B () {
echo "Stop";
}
Function C () {
Usleep (100000);
}
function sig () {
throw new Exception;
}
try{
Pcntl_alarm (1);
Pcntl_signal (SIGALRM, "sig");
A ();
Pcntl_alarm (0);
}catch (Exception $e) {
echo "Timeout";
}
b ();
A ();
b ();
For file or program code, you can use set_time_limit just to set the time-out for your PHP program.
Workaround:
1. Modify the php.ini file with the following code:
Copy the Code code as follows: Max_execution_time = 30; Maximum execution time of each script, in seconds original value 30 seconds, you can change the larger point.
After the change, remember to restart PHP, the method changed after the effective for all programs.
2. Modify your program to include the code in a script that takes more time than the default (30 seconds):
Copy the Code code as follows: Set_time_limit (300); Maximum execution time set here for 300 seconds
Set to 0 to indicate no time limit.
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/920620.html www.bkjia.com true http://www.bkjia.com/PHPjc/920620.html techarticle PHP page function to set the time-out limit method, PHP page function Timeout This article describes the PHP page function setting time-out limit method. Share to everyone for your reference. The specific method is as follows ...