計算頁面執行時間,在PHP網頁的開頭加入以下代碼:
- <?
- $time_start = getmicrotime();
- function getmicrotime()
- {
- list($usec, $sec) = explode(" ",microtime());
- return ((float)$usec + (float)$sec);
- }
- ?>
然后到最后加入以下代碼
- <?
- $time_end = getmicrotime();
- printf ("[頁面執行時間: %.2f毫秒] ",($time_end - $time_start)*1000);
- ?>
新聞熱點
疑難解答