优晟SEO

您现在的位置是:首页 > CMS教程 > 帝国cms > 正文

帝国cms

帝国cms 统计文章字数和阅读时长的代码和解决方法

佚名 2024-08-25帝国cms
把下面这个代码放在 e/class/userfun.php 里面//阅读时间functioncount_words_read_time(){global$navinfor;$text_num=mb_strlen(htmlspecialchars(strip_tags(str_replace(' ','',str_replace……

帝国cms 统计文章字数和阅读时长的代码和解决方法

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

//阅读时间functioncount_words_read_time(){global$navinfor;$text_num=mb_strlen(htmlspecialchars(strip_tags(str_replace('&nbsp;','',str_replace('&ldquo;','',str_replace('&rdquo;','',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;}

调用代码:

<?phpechocount_words_read_time();?>

标签帝国解决方法时长