<span>function </span><span>microtime_float </span><span>() </span><span>{ </span><span>list</span><span>( </span><span>$usec </span><span>, </span><span>$sec </span><span>) </span><span>= </span><span>explode </span><span>( </span><span>" " </span><span>, </span><span>microtime </span><span>()); </span><span>$sec</span><span>=(string)</span><span>$sec</span><span>; </span><span>$sec</span><span>=</span><span>substr</span><span>(</span><span>$sec</span><span>,</span><span>-</span><span>4</span><span>); </span><span>return </span><span>(</span><span>(float) </span><span>$sec </span><span>+(float)</span><span>$usec</span><span>); </span><span>} 这段代码只能计算到时间戳后四位的结果,大概就是一小时之内的执行时间,想要检测更多的话,只要 修改substr中的截取的长度,但是要注意哈,float最大只支持14位哦。 </span>
以上就介绍了 分享一个PHP代码的执行时间,精确到微秒级,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。