使用microtime() 能够将时间精确到秒以后4位,经过bcsub()避免得到科学计数法结果。code
<? function add($a, $b) { return $a + $b; } $start = microtime(true); $result = add(99, 88888); $end = microtime(true); $usedTime = bcsub($end, $start, 4); echo $usedTime;