帝国cms的简介截取字符时出现html的解决方法
2013-11-25 02:34
447 查看
我的解决方法如下,写了个函数加进去,大家看看是否可行,有咩有问题,我感觉还行
首先在 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>';
这样问题就解决了,很简单吧.
由于世界买家网和company list两个都是中英文的网站,网站名称需要用到标题,所以这样修改就很方便了
看看还有没有问题呢?
首先在 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>';
这样问题就解决了,很简单吧.
由于世界买家网和company list两个都是中英文的网站,网站名称需要用到标题,所以这样修改就很方便了
看看还有没有问题呢?
相关文章推荐
- C#从剪贴板获取HTML格式内容含中文字符出现的问题和解决方法
- 关于javac编译时出现“非法字符:\65279”的解决方法
- VC轻松解析XML文件--CMarkup使用方法(解决解析中文字符出现乱码问题)
- 完美解决x2注册页面出现‘抱歉,你输入的用户名小于3个字符问题’的两种方法
- Discuz! 出现“您当前的访问请求当中含有非法字符“解决方法
- php读取mssql日期出现中文字符的解决方法
- web.config文件中出现特殊字符的解决方法
- html使用include出现乱码乱字符号解决方法
- php读取mssql日期出现中文字符的解决方法
- js中拼装Html时 在onclick 中传值出现问题解决办法,及替换全部的方法
- PHP substr 截取字符串出现乱码问题解决方法[utf8与gb2312]
- IE浏览器用GET方式传递中文字符出现乱码问题的解决方法
- MySQL命令行界面中出现字符错误提示的原因及解决方法
- PHP函数substr截取中文字符出现乱码的解决办法
- 帝国cms后台登陆出现空白页的问题所在及解决方法
- zencart目录页出现-c-.html网址的解决方法
- 在vs2005里把html里面的部分英文代码改为中文后再运行出现乱码的解决方法
- IE6出现重复字符的bug解决方法
- 用sublime text3编写的html网页用浏览器打开出现中文乱码的原理及解决方法
- html编写代码时,显示效果中文内容出现乱码解决方法