Home php教程 php手册 php set_time_limit()设置页面执行时间

php set_time_limit()设置页面执行时间

Mar 21, 2017 pm 03:03 PM
void

set_time_limit函数可以临时定义你当前页面的执行时间,set_time_limit(0)时页面就永远有效直到程序执行完毕了,下面我来介绍set_time_limit用法.

语法 : void set_time_limit (int seconds)

注意 : 当PHP是执行在安全模式时,set_time_limit( )将不会有结果,除非是关闭安全模式或是修改结构档案中(在PHP3中叫做php3.ini,在PHP4则叫做php.ini)的时间限制.

实例代码如下:

<?php
set_time_limit(1000) 
?>
Copy after login

当此函数被调用时, set_time_limit()会从零开始重新启动超时计数器.换句话说,如果超时默认是30秒,在脚本运行了了25秒时调用 set_time_limit(20),那么,脚本在超时之前可运行总时间为45秒.

实例代码如下:

<?php 
require_once(&#39;db.php&#39;); 
$stmt = $db->query($sql); 
while ($row = $stmt->fetchRow()) { 
    set_time_limit(0); 
    // your code here 
} 
?>
Copy after login

相关文章:

php页面最大执行时间 set_time_limit函数不起作用

php set_time_limit(0) 设置程序执行时间的函数

set_time_limit — 设置脚本最大执行时间

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)