PHP function: set_time_limit () _ PHP Tutorial

Source: Internet
Author: User
PHP function: set_time_limit (). During the previous work, I encountered a PHP function: set_time_limit (). I thought this was a very simple function, but Baidu published several articles and found that a PHP function: set_time_limit () was encountered during the previous work while using this function (). I thought this was a very simple function, but Baidu has published several articles and found that there are still many aspects worth attention when using this function.

First, the set_time_limit () function is used to control the running time of the PHP page. This function is required when a PHP page in our program contains a large amount of data, for example, when a program is circulating for 1 million times or reading a large amount of data from the database.

Set_time_limit () accepts an integer parameter, which represents the maximum execution time of the page, in seconds. The default execution time is 30 seconds. when the number of seconds is set to 0, it indicates that the operation lasts for a long time. For example:

Set_time_limit (300)-indicates that the maximum page execution time is 300 seconds.

Set_time_limit (0) -- indicates that the page will continue to run.

The preceding figure shows the basic usage of the set_time_limit () function. This function is easy to use, but you must pay attention to the following points when using this function. Otherwise, this function may not work or be improperly used.

1. when using this function, you need to disable the PHP Security mode, that is, you need to set the safe_mode value in the PHP configuration file.

Set to off.

2. this function is the same as the max_execution_time option in the PHP configuration file and is used to control the page execution time.

3. according to the explanation of the function in the PHP Manual, when the function is called, the program's timeout counter will be reset to 0, that is, the page's execution time will start from 0. For example, the maximum execution time of a page is 30 seconds by default, but when the page is executed for 20 seconds, the set_time_limit (30) function is called ), the maximum page execution time is (20 + 30) = 50 seconds. That is to say, the maximum execution time of the page = the time when the current script has been executed + the time set by the set_time_limit () function.

Merge (). I thought this was a very simple function, but Baidu published several articles and found that when using this function...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.