3

I am running PHP 7.0.22 and have a problem while trying to set the max_execution_timeout option inside a PHP script. max_execution_timeout is set correctly but it is not taken into consideration by PHP:

<?php

...
$iniset = ini_set('max_execution_time', 120 * 60); // 2 hours
$iniget = ini_get('max_execution_time'); 
var_dump($iniset, $iniget);
...

And here is the output:

string '30' (length=2) string '7200' (length=4)

( ! ) Fatal error: Maximum execution time of 120 seconds exceeded in file.php on line 425

As you can see, the limit is increased to 7200 seconds, but then the script execution breaks after 120 seconds, as shown by the fatal error.

How is that possible?

P.S.: I have Xdebug installed, maybe it can cause this issue.

Thank you for your attention.

tonix
  • 6,671
  • 13
  • 75
  • 136
  • 1
    Do you have *safe mode* on? Have you tried `set_time_limit(7200)`? http://php.net/manual/en/info.configuration.php#ini.max-execution-time – Justinas Nov 17 '17 at 15:11
  • Safe mode is disabled – tonix Nov 17 '17 at 15:17
  • I noticed also this thing: when Xdebug is active and I am debugging the code, max_execution_time cannot be changed and is set to `0`, but PHP still returns the fatal error `( ! ) Fatal error: Maximum execution time of 120 seconds exceeded in file.php on line 425`. Do you know why this happens? – tonix Nov 17 '17 at 15:22
  • `set_time_limit` Doesn't work too, I still face the error: `( ! ) Fatal error: Maximum execution time of 120 seconds exceeded in file.php on line 425`. As safe mode is not enabled, what could it be due to? – tonix Nov 17 '17 at 15:28

1 Answers1

0

As you mention you have safe mode disable, and ini_set() is not working. The only workaround is to changing the time limit in the php.ini.

Viraj Shah
  • 369
  • 1
  • 4
  • 11