1. 程式人生 > >獲取php頁面的執行時間

獲取php頁面的執行時間

在檔案頭加入
$stime=microtime(true); 
在檔案尾加入
$etime=microtime(true);//獲取程式執行結束的時間
$total=$etime-$stime;   //計算差值

echo "<br />[頁面執行時間:{$total} ]秒";
這樣就能計算PHP執行時間。包括ecshop等開源程式都是用這種方法獲取的。