解析PHP计算页面执行时间的实现代码_php技巧
程序员文章站
2022-05-13 23:28:47
...
如下所示:
$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['REQUEST_TIME_FLOAT']))
echo '
else
echo '
}
}
复制代码 代码如下:
$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['REQUEST_TIME_FLOAT']))
echo '
本次执行时间:', microtime(TRUE) - $this->microtime, '秒
'; else
echo '
本次执行时间:', microtime(TRUE) - $_SERVER['REQUEST_TIME_FLOAT'], '秒
'; }
}
下一篇: 一个odbc连mssql分页的类_PHP