PHP set_time_limit of 0 sets the execution time of the program

  • 2020-03-31 20:49:10
  • OfStack

Set_time_limit (0);

The number in parentheses is the execution time, if zero means that the execution will continue until the end of the program, if the number is greater than zero, whether the program is finished or not, at the set number of seconds, the program is finished.

A simple example shows 1500 statements in the web page. If the expiration time is not set, the program will end at 791. If the previous annotation // is removed, the program does not end until 1.
 
<?php 
//set_time_limit(0); 
$i=1500; 
include ("inc/conn.php"); 
while($i>0) 
{ 
$sql="INSERT INTO php (php) 
VALUES ('$i')"; 
if ($conn->execute($sql)===flase) 
{ 
//Echo "data insertion error ".$conn-> Errormsg ();
} 
else 
{ 
$phpid=$conn->Insert_ID(); 
echo $i." In the database , No. : ".$phpid; 
} 
$i--; 
echo "<hr>"; 
} 
?> 

Related articles: