自己写了个计算页面执行时间的脚本
执行时间会显示在页面右上角
优点是只要在开始的时候执行一下就可以了
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
}
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号