Get max_execution_time in PHP script

I know that you can set the maximum runtime in a script using:

ini_set('max_execution_time', 30); 

or

 set_time_limit(30); 

What can I do to get a variable containing the maximum execution time in seconds?

+49
php
Dec 19 '11 at 1:58 p.m.
source share
4 answers

The converse using ini_get :

 ini_get('max_execution_time'); 

Note. If you check the documentation page for ini_set , you can find ini_get , which shows the note in the See Also section. This is a very good way to discover the functionality built into PHP that you still don't know about.

+98
Dec 19 '11 at 2:00
source share
— -

you can try

 $max_time = ini_get("max_execution_time"); echo $max_time; 

and you can use this variable as you want :)

+15
Dec 19 '11 at 2:03
source share

try the following:

 ini_get('max_execution_time') 
+10
Dec 19 '11 at 2:01 a.m.
source share

There are some inaccuracies in the comments. So, to clarify:

  • set_time_limit(30) same as ini_set('max_execution_time', 30);
  • Both of them reset counter.
  • ini_get('max_execution_time') works for both cases - set_time_limit and ini_set .
+9
Oct 28 '14 at 21:28
source share



All Articles