zoukankan      html  css  js  c++  java
  • 帝国 标签模板 使用程序代码 去除html标记 并 截取字符串

    在使用帝国标签模板的时候,在需要截取字符串,但是如果设置简介截取字数就会出现前台显示出来html标签的问题。现公布下我的解决方法。本人帝国初次使用者。方法如果弊病 欢迎高手留言评论。忘共同交流

    帝国 标签模板 使用程序代码 去除html标记 并 截取字符串

    1.在 e/class/connect.php 文件中加入自定义函数 去除html标记的方法 NoHTML() 

     

     1 //去除HTML标记
     2 function NoHTML($string){
     3     $string = preg_replace("'<script[^>]*?>.*?</script>'si", "", $string);//去掉javascript
     4     $string = preg_replace("'<[\/\!]*?[^<>]*?>'si", "", $string);         //去掉HTML标记
     5     $string = preg_replace("'([\r\n])[\s]+'", "", $string);               //去掉空白字符
     6     $string = preg_replace("'&(quot|#34);'i", "", $string);               //替换HTML实体
     7     $string = preg_replace("'&(amp|#38);'i", "", $string);
     8     $string = preg_replace("'&(lt|#60);'i", "", $string);
     9     $string = preg_replace("'&(gt|#62);'i", "", $string);
    10     $string = preg_replace("'&(nbsp|#160);'i", "", $string);
    11     return $string;
    12 } 

    2.列表内容模板代码:

     

    1 $r[smalltext]=esub(NoHTML($r[smalltext]),200,'......');
    2 $listtemp='<li><strong><a href="[!--titleurl--]">[!--title--]</a></strong><p>[!--smalltext--]</p></li>';

    大功告成。 

  • 相关阅读:
    程序由多个文件组成时、 头文件
    c++ 数组,变量,指针,引用, 初始化,赋值
    linux 远程装机
    linux中firewall与iptables防火墙服务
    linu samba服务
    linux 中iscsi服务
    Linux中apache服务
    linux dns高速缓存
    linux 网络配置
    linux 数据库管理
  • 原文地址:https://www.cnblogs.com/yanzhen/p/2375518.html
Copyright © 2011-2022 走看看