>  기사  >  php教程  >  PHP는 페이지 실행 시간을 계산합니다.

PHP는 페이지 실행 시간을 계산합니다.

大家讲道理
大家讲道理원래의
2016-11-11 10:29:551492검색

<?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;;
    }
}

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.