Typecho程序如何在主题添加当前页面加载完成时间 ssr 2022-02-26 软件分享 选项 默认字体 ✓ 楷体 ✓ 霞鹜文楷体 ✓ 小 ✓ 中 ✓ 大 ✓ 阅读模式 编辑 我们经常看到有些网友的 Typecho 网站底部会有一个加载完成时间,这个虽然用途不大,但是可以看到当前页面的加载速度,比如是否需要调整网站速度。以及对网站进行优化处理。在这篇文章中,我们 Typecho 主题插件网可以整理出来 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;}Plain text复制 第二、在需要提交的位置 <?php echo timer_stop();?>Plain text复制 在我们需要添加的位置加上代码即可。
评论区(暂无评论)