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();

相关文章

ThinkPHP使用心得分享-分页类Page的用法

ThinkPHP中的Page类在ThinkPHP/Extend/Library/ORG/Util/Page.class.php中,所以使用前要引入Page类: 复制代码 代码如下:imp...

php常用的安全过滤函数集锦

php常用的安全过滤函数集锦

虽然各种开发框架给我们提供了很好的安全的处理方式,但是,我们还是要注意一下安全问题的。  原因简单:很多小的功能和项目是用不到框架的,我们需要自己解决安全问题! ①常用的安全函...

php ignore_user_abort与register_shutdown_function 使用方法

语法: int ignore_user_abort(int [setting]); 返回值: 整数 函数种类: PHP 系统功能 内容说明 0 - NORMAL(正常)1 - ABORT...

php中magic_quotes_gpc对unserialize的影响分析

本文实例分析了php中magic_quotes_gpc对unserialize的影响。分享给大家供大家参考。具体如下: magic_quotes_gpc是一个php中一个给单双引号增加一...

浅谈使用PHP开发微信支付的流程

下面以PHP语言为例,对微信支付的开发流程进行一下说明。 1.获取订单信息 2.根据订单信息和支付相关的账号生成sign,并且生成支付参数 3.将支付参数信息POST到微信服务器,获取返...