解析PHP计算页面执行时间的实现代码

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

<?php
 $t = new executeTime;
 phpinfo();
 class executeTime{
     private $microtime;
     public function __construct(){
         $this->microtime = microtime(true);
     }

         public function getNow(){
                 $this->__dectruct();
         }

     public function __destruct(){
         if (empty($_SERVER['REQUEST_TIME_FLOAT']))
             echo '<div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:', microtime(TRUE) - $this->microtime, '秒</div>';
         else
             echo '<div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:', microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], '秒</div>';
     }
 }

相关文章

php 常用的系统函数

字符串函数 strlen:获取字符串长度,字节长度 substr:字符串截取,获取字符串(按照字节进行截取) strchr:与substr相似,从指定位置截取一直到最后 strrchr(...

功能强大的PHP POST提交数据类

本文实例为大家分享了PHP功能强大的 POST提交数据类,供大家参考,具体内容如下 <?php class Request{ public static fun...

ie与session丢失(新窗口cookie丢失)实测及解决方案

今天在一个群中有人问到ie6中使用js的open,发现新窗口中并获取不到session, 经过使用下面的测试代码测试发现,是因为phpsessionid储存是进程级的有效期,只有同一进程...

PHP 数据库树的遍历方法

代码如下: 复制代码 代码如下:<?php session_start(); define ('P_S', PATH_SEPARATOR); define ('ROOT', "./...

php的chr和ord函数实现字符加减乘除运算实现代码

chr函数用于将ASCII码转换为字符 ord函数是用来字符转换为ASCII码 ASCII码是计算机所能显示字符的编码,它的取值范围是0-255,其中包括标点、字母、数字、汉字等。在编程...