Home  >  Article  >  Backend Development  >  php set_time_limit() sets page execution time_PHP tutorial

php set_time_limit() sets page execution time_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:14:581307browse

The set_time_limit function can temporarily define the execution time of your current page. When set_time_limit(0), the page will be valid forever until the program execution is completed. Let me introduce the usage of set_time_limit.

Syntax: void set_time_limit (int seconds)

Note: When PHP is running in safe mode, set_time_limit() will have no results unless safe mode is turned off or the structure file is modified (called php3.ini in PHP3 and php.ini in PHP4 ) time limit.

Example

The code is as follows
 代码如下 复制代码

set_time_limit(1000)

?>

Copy code

set_time_limit(1000)

代码如下 复制代码

require_once('db.php');

$stmt = $db->query($sql);

while ($row = $stmt->fetchRow()) {
    set_time_limit(0);
    // your code here
}

?>

?>

When this function is called, set_time_limit() will restart the timeout counter from zero. In other words, if the default timeout is 30 seconds and set_time_limit(20) is called when the script has been running for 25 seconds, then the total time the script can run before timing out is 45 seconds.

The code is as follows Copy code
require_once('db.php'); $stmt = $db->query($sql); while ($row = $stmt->fetchRow()) {
set_time_limit(0);
// your code here
} ?>
http://www.bkjia.com/PHPjc/628894.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/628894.htmlTechArticleThe set_time_limit function can temporarily define the execution time of your current page. When set_time_limit(0), the page will be valid forever until the program is executed. That's it. Let me introduce the usage of set_time_limit. ...
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