php set_time_limit(0) function to set program execution time

高洛峰
Release: 2023-03-04 20:28:02
Original
1657 people have browsed it

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, it will not matter whether the program execution is completed or not, it will reach the set time. seconds, the program ends.

A simple example is to display 1500 statements on a web page. If the expiration time is not set, the program execution will end at 791. If the comment character // before set_time_limit(0); is removed, then 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 (&#39;$i&#39;)"; 
if ($conn->execute($sql)===flase) 
{ 
//echo "数据插入错误".$conn->errormsg(); 
} 
else 
{ 
$phpid=$conn->Insert_ID(); 
echo $i."已经存入数据库,编号:".$phpid; 
} 
$i--; 
echo "<hr>"; 
} 
?>
Copy after login

For more php set_time_limit(0) function to set program execution time related articles, please pay attention to the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!