PHP教程之一个页面执行时间类_PHP教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:PHP实例:将IP最后一位替换为星号
将IP最后一位替换为星号 代码如下: ?php str = '1.1.1.1'; reg = '/((?:\d+\.){3})\d+/'; echo preg_replace(reg, \\1*, str); ?

PHP代码
<?php
class Timer//页面执行时间类
{
var starttime;//页面开始执行时间
var stoptime;//页面结束执行时间
var spendtime;//页面执行花费时间

function getmicrotime()//获取返回当前微秒数的浮点数
{
list(usec,sec)=explode(" ",microtime());
return ((float)usec + (float)sec);
}

function start()//页面开始执行函数,返回开始页面执行的时间
{
this->starttime=this->getmicrotime();
}

function display()//显示页面执行的时间
{
this->stoptime=this->getmicrotime();
this->spendtime=this->stoptime-this->starttime;
return round(this->spendtime,10);
}
}
/*调用方法
timer=new Timer();
timer->start();
/*在此处放入你要执行的脚本或代码
for(i=0;i<100000;i++)
{
echo i;
echo "<br>";
}
*/
//echo "<p>执行该代码花费时间".timer->display()."秒";
?>
 

分享:PHP教程之多文件上传类
PHP多文件上传类 /* 多文件上传类 修改:Linvo 2008-2-15 */ class more_file_upload{ const FILE_PATH='../upfileclass/uploadfile/'; var file_type; var file_type_array; var file_type_real_array; var file_type_string; var file_name; var file_size

来源:模板无忧//所属分类:PHP教程/更新时间:2010-03-05
相关PHP教程