Typecho是一款体验友好。运行流畅的轻量级开源跨平台博客程序。这里我们使用BlueHost美国主机搭建了一个Typecho博客网站。如果想要了解当前页面加载是否快速。我们可用下面方法来获取页面加载时间。
1。在Typecho当前主题的functions.php文件中添加下面代码:
function timer_start() {
global $timestart;
$mtime = explode( ‘ ‘, microtime() );
$timestart = $mtime[1] + $mtime[0];
return true;
}
timer_start();
function timer_stop( $display = 0, $precision = 3 ) {
global $timestart, $timeend;
$mtime = explode( ‘ ‘, microtime() );
$timeend = $mtime[1] + $mtime[0];
$timetotal = number_format( $timeend – $timestart, $precision );
$r = $timetotal < 1 ? $timetotal * 1000 . ” ms” : $timetotal . ” s”;
if ( $display ) {
echo $r;
}
return $r;
}
2。然后在要显示加载时间的位置添加调用代码:
<?php echo timer_stop();?>
3。代码添加完成后。保存文件。接着到Typecho前台刷新页面即可显示加载时间。
以上是关于Typecho获取当前页面加载时间的方法介绍。操作还是比较简单的。只需在主题配置文件中添加相应的代码段。然后在模块中调用。便可以在前台查看到页面的加载时间。
本文地址:https://gpu.xuandashi.com/33448.html,转载请说明来源于:渲大师
声明:本站部分内容来自网络,如无特殊说明或标注,均为本站原创发布。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。分享目的仅供大家学习与参考,不代表本站立场!