zoukankan      html  css  js  c++  java
  • PHP去掉所有HTML代码

    function replaceHtmlAndJs($document)
    {
     $document = trim($document);
     if (strlen($document) <= 0)
     {
        return $document;
     }
     $search = array ("'<script[^>]*?>.*?</script>'si",  // 去掉 javascript
                      "'<[\/\!]*?[^<>]*?>'si",          // 去掉 HTML 标记
                      "'([\r\n])[\s]+'",                // 去掉空白字符
                      "'&(quot|#34);'i",                // 替换 HTML 实体
                      "'&(amp|#38);'i",
                      "'&(lt|#60);'i",
                      "'&(gt|#62);'i",
                      "'&(nbsp|#160);'i",
          "\"",
          "\'",
                      );                    // 作为 PHP 代码运行
     $replace = array ("",
                       "",
                       "\\1",
                       "\"",
                       "&",
                       "<",
                       ">",
                       " ",
           " ",
           " "
                       );
     return @preg_replace ($search, $replace, $document);
    }
  • 相关阅读:
    shell数组
    Apache HTTP Server 与 Tomcat 的三种连接方式介绍
    实现Java动态类载入机制
    Tomcat 阀
    MYSQL 常用命令
    MYSQL字符数字转换
    主题:MySQL数据库操作实战
    日本手机三大代理商的UA
    Java解析XML文档——dom解析xml (转载)
    MS sql server和mysql中update多条数据的例子
  • 原文地址:https://www.cnblogs.com/kuyuecs/p/1447059.html
Copyright © 2011-2022 走看看