<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教程有興趣的朋友有所幫助。