php代码运行时间查看类代码分享

yipeiwu_com6年前PHP代码库
复制代码 代码如下:

//date:2011-08-05
class RunTime//页面执行时间类
{
private $starttime;//页面开始执行时间
private $stoptime;//页面结束执行时间
private $spendtime;//页面执行花费时间
function getmicrotime()//获取返回当前微秒数的浮点数
{
list($usec,$sec)=explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function start()//页面开始执行函数,返回开始页面执行的时间
{
$this->starttime=$this->getmicrotime();
}
function end()//显示页面执行的时间
{
$this->stoptime=$this->getmicrotime();
$this->spendtime=$this->stoptime-$this->starttime;
//return round($this->spendtime,10);
}
function display()
{
//$this->end();
echo "<p>运行时间:".round($this->spendtime,10)."秒</p>";
}
}
/*调用方法
$timer=new Runtime();
$timer->start();

相关文章

PHP中file_exists函数不支持中文名的解决方法

一般来说PHP中常使用file_exists()判断某个文件或者文件夹是否存在,如果存在则返回true,否则返回false。但是该函数在网页使用UTF8编码的情况下,对于中文的文件名或者...

PHP实现批量删除(封装)

前台 <!DOCTYPE html> <html> <head> <title>批量删除</title> </h...

php实现session自定义会话处理器的方法

本文实例讲述了php实现session自定义会话处理器的方法。分享给大家供大家参考。具体分析如下: session自定义会话处理器,即就是说,所有关于session的各种操作,都可以通过...

PHP实现对图片的反色处理功能【测试可用】

PHP实现对图片的反色处理功能【测试可用】

本文实例讲述了PHP实现对图片的反色处理功能。分享给大家供大家参考,具体如下: 今天有个需求用php对图片进行反色,和转灰,之前不知道可不可行,后来看到了imagefilter()函数,...

CodeIgniter与PHP5.6的兼容问题

错误提示: A PHP Error was encountered Severity: Notice Message: Only variable references shou...