PHP计算页面执行时间
run_time.php Code:
<?php
class runtime
{
var $StartTime = 0;
var $StopTime = 0;
function get_microtime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float)$usec + (float)$sec);
}
function start()
{
$this->StartTime = $this->get_microtime();
}
function stop()
{
$this->StopTime = $this->get_microtime();
}
function spent()
{
return round(($this->StopTime - $this->StartTime) * 1000, 1);
}
}
?>
return_time_test.php Code:
<?php
include ('run_time.php');
$runtime = new runtime;
$runtime->start();
$a = 0;
for ($i=0;$i<rim(1000000);$i++){
$a += $i;
}
$runtime->stop();
echo "页面执行时间:".$runtime->spent()."毫秒!";
?>
相关文档:
开源建站程序让编程高手和只懂打字上网的人都可以快速建立一个功能强大、界面漂亮的网站。不管你是想建一个博客、论坛、CMS、电子商务网站,或是Wiki、相册管理、RSS聚合和类Digg网站。你都可以通过这些建站工具快速建立。
我们之前介绍过23个开源的CMS管理系统,现在则让我们来看一下26款开源建站程序。
国外PHP开源建 ......
为了脚本程序的兼容性,很多时候脚本的名称都不是固定的。所以我们需要通过动态获取当前脚本的路径、文件名来完成某些功能。
PHP 中,我们可以使用常量 __FILE__ 来获取当前被执行脚本的完整路径。
注意:当包含此变量的脚本被其他脚本include或者require的时候, __FILE__ 将仍然返回此脚本的地址,而不是 ......
<?php
header("Content-Type:image/png");
srand((double)microtime()*1000000);
$img_height=20;
$img_width=60;
$im=@imagecreate($img_width,$img_height) or die("不能初始化GD文件流");
$background_color=imagecolorallocate($im,255,255,255);
$text_color=imagecolorallocate($im,233,14,91);
......