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;

}

在footer.php底部合适的位置添加:

<?php echo timer_stop();?>

© 版权声明
THE END
喜欢就支持一下吧!
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片快捷回复

    暂无评论内容