欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

解析PHP计算页面执行时间的实现代码_php技巧

程序员文章站 2022-05-08 16:03:22
...
如下所示:
复制代码 代码如下:

$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'], '秒
';
}
}