用php得到页面的执行时间
<?
/*
得到一个页面的执行时间,并显示出来。
get_microtime()函数可以保存在公共函数文件中供各个页面调用。
*/
function get_microtime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
?>
<?
//include('include/function.php');
$time_start = get_microtime();
echo "hello 1";
?>
<?
for($i=0;$i<100000;$i++)
{
echo "$i aa";
}
?>
<?
echo "hello 2<br>";
$time_end = get_microtime();
$time = $time_end - $time_start;
echo $time;
?>
seconds.
博客介绍了用PHP获取页面执行时间的方法。定义了get_microtime()函数,可保存在公共函数文件供各页面调用。通过该函数记录页面开始和结束时间,计算差值得到执行时间并显示。
8870

被折叠的 条评论
为什么被折叠?



