Typecho文章字数统计

在当前使用的主题的根目录的 functions.php 插入如下代码

function  art_count ($cid){
    $db=Typecho_Db::get ();
    $rs=$db->fetchRow ($db->select ('table.contents.text')->from ('table.contents')->where ('table.contents.cid=?',$cid)->order ('table.contents.cid',Typecho_Db::SORT_ASC)->limit (1));
    $text = preg_replace("/[^\x{4e00}-\x{9fa5}]/u", "", $rs['text']);
    echo mb_strlen($text,'UTF-8');
}

在需要引用的地方插入

<?php art_count($this->cid); ?>

生成海报
点赞 1

陌涛

这个博主很懒,懒死了。

暂无评论

发表评论

您的电子邮件地址不会被公开,必填项已用*标注。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据

相关推荐