PHP function: set_time_limit

Source: Internet
Author: User
PHP function: set_time_limit function definition:

Void set_time_limit (int $ seconds)

Set the time allowed for script running, 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 of php. ini. if this value exists.

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 25 seconds are set in the script, for example, set_time_limit (20 ). The total running time of the script before the timeout is 45 seconds.

This function is invalid in security mode.

The set_time_limit () function and the configuration command max_execution_time only affect the execution time of the script. The operation of running the program at any time, such as using system (), stream operation, database query, etc., is executed in the script, not included in the specified maximum time, the script has been run. This is not true in Windows, because the measurement time is real.

The sleep () function varies depending on the operating system. the duration of running the program in linux is ignored, and the duration of running the program in windows is included.

Example 1:

 

Example 2:

 

Note: In linux, sleep does not work. in windows, a timeout message is reported without any output.

Example 3:

 ";}Error_reporting ($ es); // restore the function time_out_callback () {if (connection_status () = 2) {B () ;}} function B () {echo 'Hello world! ';}?>

Timeout error capture.

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.