我的解决方法如下,写了个函数加进去,大家看看是否可行,有咩有问题,我感觉还行 首先在 e/class/connect.PHP 文件中加入一个自定义函数 比如 Nohtml() 这个自己喜欢随便设置 复制代码代码如下: /
我的解决方法如下,写了个函数加进去,大家看看是否可行,有咩有问题,我感觉还行
首先在 e/class/connect.PHP 文件中加入一个自定义函数 比如 Nohtml() 这个自己喜欢随便设置
复制代码代码如下:
//去除HTML标记
function NoHTML($string){
$string = preg_replace("'<script[^>]*?>.*?</script>'si", "", $string);//去掉javascript
$string = preg_replace("'<[\/\!]*?[^<>]*?>'si", "", $string); //去掉HTML标记
$string = preg_replace("'([\r\n])[\s]+'", "", $string); //去掉空白字符
$string = preg_replace("'&(quot|#34);'i", "", $string); //替换HTML实体
$string = preg_replace("'&(amp|#38);'i", "", $string);
$string = preg_replace("'&(lt|#60);'i", "", $string);
$string = preg_replace("'&(gt|#62);'i", "", $string);
$string = preg_replace("'&(nbsp|#160);'i", "", $string);
return $string;
}
然后去列表内容模板修改代码即可
复制代码代码如下:
$r[smalltext]=esub(NoHTML($r[smalltext]),200,'......');
$listtemp='<li><strong><a href="[!--titleurl--]">[!--title--]</a></strong><p>[!--smalltext--]</p></li>';
这样问题就解决了,很简单吧.
由于是中英文的网站,网站名称需要用到标题,所以这样修改就很方便了
看看还有没有问题呢?
--结束END--
本文标题: 自定义函数解决帝国cms的简介截取字符时出现html的问题
本文链接: https://www.lsjlt.com/news/31937.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-02-29
2024-02-29
2024-02-27
2023-10-27
2023-10-26
2023-10-25
2023-10-21
2023-10-21
2023-10-18
2023-10-12
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0