【HR】Typecho页面加载时间代码

编程开发   © 文章版权由 admin 解释,禁止匿名转载

#楼主# 2023-1-16

【HR】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;
}

②在需要显示的位置加上如下代码,可以自行进行样式美化,我是将代码显示到了页脚



文档地址:

本帖含有隐藏内容,请您 回复 后查看

11楼
端正 2023-1-16
么么哒[十分开心][滑稽]
12楼
HRa西瓜糖 2023-1-17
那个姐姐说暂时不举[委屈]
14楼
HRa西瓜糖 2023-1-17
你先收好,
15楼
HRa西瓜糖 2023-1-17
好了。。,
16楼
贝塔123 2023-1-17
加到哪里啊[泪][泪]

18楼
陌讼蜷 2023-1-17
加到最底下就行
19楼
贝塔123 2023-1-17
好的么么哒[吐舌]
20楼
HRa西瓜糖 2023-1-17
没什么东西好发的[委屈]

评论

登录后才可发表内容
  • 主题

    95

  • 帖子

    5490

  • 关注者

    0

Copyright © 2019 凯特网.   Powered by HYBBS 2.3.4  

Runtime:0.0502s Mem:2132Kb