<code>
class timer{
private $start; //程序運行開始時間
private $end; //程序運行結束時間
private $spend; //程序運行時間
function start(){ //程序運行開始
$this->start=microtime(true);
}
function end(){//程序運行結束
$this->end=microtime(true);
}
function spend(){//程序執行時間
$this->spend=$this->end-$this->start;
return number_format($this->spend*1000,4)."毫秒";
}
}
//使用方法
// $time= new timer();
// $time->start();
// $time->end();
// $time->spend();
</code>