Home > Backend Development > PHP Problem > How to use php set_time_limit method

How to use php set_time_limit method

藏色散人
Release: 2023-03-09 19:38:01
Original
3337 people have browsed it

php The set_time_limit method is used to set the maximum execution time of the script. Its usage syntax is "set_time_limit (int $seconds): bool". The parameter seconds represents the maximum execution time in seconds.

How to use php set_time_limit method

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

set_time_limit — Set the maximum execution time of the script

Description

set_time_limit ( int $seconds ) : bool
Copy after login

Set the time allowed for the script to run, in seconds. If this setting is exceeded, the script returns a fatal error. The default value is 30 seconds, or the value defined in max_execution_time in php.ini, if this value exists.

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.

Parameters

seconds
Copy after login

Maximum execution time, in seconds. If set to 0 (zero), there is no time limit.

Return value

Returns true on success and false on failure.

Comments

Note:

The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. The maximum time for any script execution that occurs such as system calls using system(), stream operations, database operations, etc. is not included when the script is already running. In Windows, where measured times are real-valued, this is not the case.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to use php set_time_limit method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
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