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

把下面这个代码放在 e/class/userfun.php 里面
  1. // 阅读时间
  2. function count_words_read_time () {
  3.         global $navinfor;
  4.         $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');
  5.         $read_time = ceil($text_num/300); // 修改数字300调整时间
  6.         $output .= '本文共计' . $text_num . '个字,预计阅读时长' . $read_time  . '分钟。';
  7.         return $output;
  8. }
复制代码
调用代码:
<?php echo count_words_read_time(); ?>




上一篇:帝国cms灵动标签获取父栏目名字方法
下一篇:帝国cms7.5版的编辑器如何保留word格式的解决方法?
如无回复请发邮件