核心代码
starttime=this->getmicrotime();
}
function display()//显示页面执行的时间
{
this->stoptime=this->getmicrotime();
this->spendtime=this->stoptime-this->starttime;
return round(this->spendtime,10);
}
}
//echo "执行该代码花费时间".timer->display()."秒";
?>
PHP检测每一段代码执行时间
process time: ".$totaltime; } // 程序调用开始记时 proStartTime(); sleep(1); // sleep() 延时代码执行若干秒 proEndTime(); // 程序在每一段所消耗的执行时间 sleep(2); proEndTime(); sleep(3); proEndTime(); // 实例2 $t1 = microtime(true); sleep(3); $t2 = microtime(true); echo '程序耗时'.round($t2-$t1,3).'秒'; ?>



