>  기사  >  백엔드 개발  >  PHP 计算页面执行时间_PHP教程

PHP 计算页面执行时间_PHP教程

WBOY
WBOY원래의
2016-07-13 10:37:50931검색

自己写了个计算页面执行时间的脚本 
执行时间会显示在页面右上角
优点是只要在开始的时候执行一下就可以了    

代码片段(1)

[代码] [PHP]代码

01 <?php 02 $t new executeTime; 03   04 phpinfo(); 05   06 class executeTime{ 07     private $microtime; 08     public function __construct(){ 09         $this->microtime = microtime(true); 10     } 11   12         public function getNow(){ 13                 $this->__dectruct(); 14         } 15   16     public function __destruct(){ 17         if (empty($_SERVER['REQUEST_TIME_FLOAT'])) 18             echo '<div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:'<code class="plain">, microtime(TRUE) - $this->microtime, '秒
'; 19         else 20             echo '<div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:'<code class="plain">, microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], '秒
'; 21     } 22 }

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/735157.htmlTechArticle自己写了个计算页面执行时间的脚本 执行时间会显示在页面右上角 优点是只要在开始的时候执行一下就可以了 代码片段 (1) [代码] [PHP]代码...
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:解决 json_encode 中文乱码_PHP教程다음 기사:PHP攻击网站防御代码-以及攻击代码反译_PHP教程

관련 기사

더보기