Phpset_time_limit () sets the page execution time

Source: Internet
Author: User
The et_time_limit function can temporarily define the execution time of your current page. when set_time_limit (0) is used, the page will always be valid until the execution of the program is completed. next I will introduce the set_time_limit syntax: voidset_time_limit) note: When PHP is executed in the security mode

The set_time_limit function can temporarily define the execution time of your current page. when set_time_limit (0) is used, the page will always be valid until the execution of the program is completed. next I will introduce the set_time_limit usage.

Syntax: void set_time_limit (int seconds)

Note: When PHP is executed in safe mode, set_time_limit () will not produce any results, unless it is disabled in safe mode or modified in the structure file (in PHP3, it is called php3.ini, PHP4 is called php. ini.

The instance code is as follows:

  1. Set_time_limit (1000)
  2. ?>

When this function is called, set_time_limit () restarts the timeout counter from scratch. in other words, if the timeout value is 30 seconds by default and set_time_limit (20) is called when the script runs for 25 seconds, the total running time of the script before the timeout value is 45 seconds.

The instance code is as follows:

  1. Require_once ('Db. php ');
  2. $ Stmt = $ db-> query ($ SQL );
  3. While ($ row = $ stmt-> fetchRow ()){
  4. Set_time_limit (0 );
  5. // Your code here
  6. }
  7. ?>

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.