Home >Backend Development >PHP Tutorial >php set_time_limit(0) function to set program execution time

php set_time_limit(0) function to set program execution time

PHP中文网
PHP中文网Original
2017-03-21 15:02:581652browse

set_time_limit(0);

The number in the brackets is the execution time. If it is zero, it means that it will be executed permanently until the end of the program. If it is a number greater than zero, the program will end after the set number of seconds, regardless of whether the program is completed.
A simple example, display 1500 statements on a web page. If the expiration time is not set, the program will end when it reaches 791. If the comment character // before set_time_limit(0); is removed, the program will not run until 1 Just ended.

<?php 
//set_time_limit(0); 
$i=1500; 
include ("inc/conn.php"); 
while($i>0) 
{ 
$sql="INSERT INTO php (php) 
VALUES (&#39;$i&#39;)"; 
if ($conn->execute($sql)===flase) 
{ 
//echo "数据插入错误".$conn->errormsg(); 
} 
else 
{ 
$phpid=$conn->Insert_ID(); 
echo $i."已经存入数据库,编号:".$phpid; 
} 
$i--; 
echo ""; 

} 
?>

Related articles:

php page maximum execution time set_time_limit function does not work

php set_time_limit() Set page execution time

set_time_limit — Set maximum script execution time

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn