計算頁面運行時間類

<?php error_reporting(E_ALL); class RunTime{     private $startTime='';     private $endTime='';     function __construct() {         $this->startTime = $this->getMicroTimeAsFloat();     }     function getMicroTimeAsFloat(){         list($fractionalSeconds,$seconds)=explode(" ", microtime());         return ((float)$seconds + (float)$fractionalSeconds);     }     function elapsed(){         $this->endTime = $this->getMicroTimeAsFloat();         return ($this->endTime - $this->startTime);     } } 運行方式:引入該類,在頁面頭部初始化,$rt= new Runtime();  頁面底部顯示 echo $rt->elapsed();
相關文章
相關標籤/搜索