Home >Backend Development >PHP Tutorial >php-fpm - How to achieve a maximum execution time of less than one second in PHP?
Use set_time_limit to control the maximum execution time in seconds
Use set_time_limit to control the maximum execution time in seconds
<code><?php declare(ticks=1); $start = microtime(true); register_tick_function(function () use ($start) { (microtime(true) - $start < 0.5) or die("timeout\n"); }); function a() { echo "do some work\n"; usleep(600000); echo "do another work\n"; } a(); </code>
The above code shows a 500 millisecond timeout