您的位置:宽带测速网 > 帝国cms > 帝国cms内容文章统计字数和阅读时间的的方法

帝国cms内容文章统计字数和阅读时间的的方法

2025-08-25 08:56来源:互联网 [ ]

把下面这个代码放在 e/class/userfun.php 里面

// 阅读时间
function count_words_read_time () {
global $navinfor;
$text_num = mb_strlen(htmlspecialchars(strip_tags(str_replace(' ','',str_replace('“','',str_replace('”','',str_replace(egetzy('rn'),'',str_replace(egetzy('<br />'),'',$navinfor[newstext]))))))),'utf-8');
$read_time = ceil($text_num/300); // 修改数字300调整时间
$output .= '本文共计' . $text_num . '个字,预计阅读时长' . $read_time. '分钟。';
return $output;
}
调用代码:
<?php echo count_words_read_time(); ?>