0

Is there any way to set php max execution time less than a second?

or

How can we handle it in code level like return a json message to show "Exceeded max allowed response time"?

Ramesh
  • 3
  • 2

1 Answers1

0

No, you can't set max_execution_time less than the seocond. Also, You can not change this setting with ini_set() when running in safe mode. The only workaround is to turn off safe mode or by changing the time limit in the php.ini. max_execution_time

But you can emulate it with a function as this post

declare(ticks=1);
$start = microtime(1);
register_tick_function(function () use ($start) {
   (microtime(1) - $start < 0.8) or die();
});
Community
  • 1
  • 1