Heim  >  Artikel  >  php教程  >  PHP 计算页面执行时间

PHP 计算页面执行时间

大家讲道理
大家讲道理Original
2016-11-11 10:29:551492Durchsuche

<?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[&#39;REQUEST_TIME_FLOAT&#39;]))
            echo &#39;<div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:&#39;, microtime(TRUE) - $this->microtime, &#39;秒</div>&#39;;
        else
            echo &#39;<div style="color:#fff;background:#000;position:absolute;top:0px;right:0px;padding:3px 6px;">本次执行时间:&#39;, microtime(TRUE) - $_SERVER[&#39;REQUEST_TIME_FLOAT&#39;], &#39;秒</div>&#39;;
    }
}

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php XSS安全过滤代码Nächster Artikel:php控制文件下载速度