Typecho 页面载入时间代码
有些主题可能用到加载条,需要判断加载时间,就要用到如下代码了
<?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 = $timeend - $timestart; $r = number_format( $timetotal, $precision ); if ( $display ) echo $r; return $r; } ?>
<?php echo 'Loading spends ',timer_stop(), ' s.';?>
调用代码:
觉得文章有用就打赏一下文章作者
微信扫一扫打赏
![](/skin/images/wxskm.jpg)