phpcms 过滤内容中无用标签的方法
(2014-03-22 11:27:50)
标签:
手机版
过滤
php
大印工作室
pc版:先在phpcms\modules\content\functions目录下的global.func.php内
添加一个函数
手机版:先在phpcms\modules\wap\functions目录下的global.func.php内 添加一个函数
function guolv($str) {
$str = preg_replace("/< a[^>]*>/i", "", $str);
$str = preg_replace("//i", "", $str);
$str = preg_replace("/< script[^>]*>/i", "", $str);
$str = preg_replace("//i", "", $str);
$str = preg_replace("/< iframe[^>]*>/i", "", $str);
$str = preg_replace("//i", "", $str);
$str = preg_replace("/< style[^>]*>/i", "", $str);
$str = preg_replace("//i", "", $str);
$str = preg_replace("/< div[^>]*>/i", "", $str);
$str = preg_replace("//i", "", $str);
return $str;
}
然后在后台的模板编辑里找到show.html;
在想要过滤的标签中加上{guolv(字段标签)};例如:将{$content}改为{guolv($content)}
分享:
喜欢
0
赠金笔
加载中,请稍候......
评论加载中,请稍候...
发评论
登录名: 密码: 找回密码 注册记住登录状态
昵 称:
评论并转载此博文

发评论
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。
本文介绍了一种在PHPCMS中过滤HTML内容中的特定标签的方法,通过编写正则表达式匹配并删除如a、script等标签,确保内容的纯净。
1767

被折叠的 条评论
为什么被折叠?



