确定了PHP脚本所需的时间执行正确的一微秒。
插入在页面顶部的代码:
$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
?>
然后添加在页面底部的以下内容:
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
echo 'This page was created in ' .$totaltime. ' seconds.';
?>
PHP的microtime中()函数返回当前的Unix时间戳微秒。