欢迎光临
我们一直在努力

这有一个测试页面执行时间的类:-PHP教程,PHP应用

建站超值云服务器,限时71元/月

<?
class timer {  
    var $starttime = 0;  
    var $stoptime = 0;  
    var $timespent = 0;  

    function start(){  
        $this->starttime = microtime();  
    }  

    function stop(){  
        $this->stoptime  = microtime();  
    }  

    function spent() {  
        if ($this->timespent) {  
            return $this->timespent;  
        } else {  
            $startmicro = substr($this->starttime,0,10);  
            $startsecond = substr($this->starttime,11,10);  
            $stopmicro  = substr($this->stoptime,0,10);  
            $stopsecond  = substr($this->stoptime,11,10);  
            $start = doubleval($startmicro) + $startsecond;  
            $stop  = doubleval($stopmicro) + $stopsecond;  
            $this->timespent = $stop – $start;  
            return substr($this->timespent,0,8)."秒";  
        }  
    }  // end function spent();  

} //end class timer;  

//例子:  
    $timer = new timer;  
    $timer->start();  
/*
你的代码放在此处
*/

    $timer->stop();  
    echo "执行本script共".$timer->spent();  
?>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 这有一个测试页面执行时间的类:-PHP教程,PHP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章