zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Typecho显示服务器内存占用

2023-04-18 15:57:12 时间

Typecho博客系统显示服务器占用内存的插件,代码很简单,这插件作者是12年写的,我用了已经不能用,我通过自学的一丢丢的PHP基础,简单的整理了一下,又能用了,奇怪的知识又涨了

插件截图

调用代码

<?php QiangZai_Plugin::put(); ?>

插件下载

本地下载 网盘下载

补充说明

如果你不会弄加载时间,看这里吧 在 functions.php 中加入以下代码:

/**
 * 加载时间
 * @return bool
 */
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;
}

然后,在模板中引用:

<?php echo timer_stop();?>

结语

代码自行放在显示的位置即可,比如我放在了页面底部的footer.php里面