Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is set_time_limit() global or only for the current running script?

Tags:

php

timeout

I've got a very ugly page where I've had to set max timeout to 2 minutes in PHP for the moment. I'm using the set_time_limit() function, but from the official documentation I wasn't clear how global the "setting" is.

This blurb seems to imply it's limited to the specific script:

The set_time_limit() function and the configuration directive max_execution_time only affect the execution time of the script itself. Any time spent on activity that happens outside the execution of the script such as system calls using system(), stream operations, database queries, etc. is not included when determining the maximum time that the script has been running. This is not true on Windows where the measured time is real.

Basically I want to double check, setting this one-time in one script doesn't affect the max run time for any other script at all, does it? Running any other page will still have the default timeout? No other page (in fact no other function) requires this timeout.

like image 919
Ben Brocka Avatar asked May 01 '12 14:05

Ben Brocka


People also ask

What is the default execution time set in set_time_limit ()?

The default limit is 30 seconds or, if it exists, the max_execution_time value defined in the php. ini . When called, set_time_limit() restarts the timeout counter from zero.

What is Max execution time?

Maximum execution time (max_execution_time) is a time limit on how long a PHP script can run. It is a way hosting providers can limit the use and abuse of server resources, especially for shared hosting. The actual default value depends on the hosting, but it-s usually set to 30 (i.e. 30 seconds).

Is it possible to extend the execution time of a PHP script?

Yes, it is possible to set an infinite execution time for the PHP Script.


1 Answers

Only for the currently running script.

like image 122
Niet the Dark Absol Avatar answered Sep 19 '22 13:09

Niet the Dark Absol