Home > Article > Backend Development > section php max_execution_time execution time problem
The default maximum execution time in php.ini is 30 seconds, which is specified by the max_execution_time variable in php.ini. If you have a job that takes a long time to complete, such as sending a lot of emails to a large number of recipients, Or, if you want to perform heavy data analysis work, the server will forcibly terminate the executing program after 30 seconds. How to solve this problem?
The simplest course is to modify the value of max_execution_time in php.ini. However, not everyone has the right to modify php.ini, such as developers who use web hosting. The php.ini on the server is used by many websites, so it cannot be modified at will. .
Another way is to add ini_set('max_execution_time', '0') to the PHP program. A value of 0 means there is no execution time limit. Your program can run as long as it needs to. If your program is still in the testing stage, it is recommended that you set the time limit to a real number to prevent program errors from crashing the server.
Copy the code The code is as follows:
//max_executi
ini_set("max_execution_time", 1); //Use this function to really set it at runtime
for($i=1 ; $i< 100000; $i++)
{
echo "No. {$i}n";
echo '
';
flush();
}
?>
The above introduces the section php max_execution_time execution time issue, including the section content. I hope it will be helpful to friends who are interested in PHP tutorials.