<?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(); 以上代码展示一个500毫秒的超时
以上代码展示一个500毫秒的超时