时时商务社区

标题: php下过滤HTML代码的函数 [打印本页]

作者: 阿情    时间: 2018-2-14 09:24

            /*----------------------
过滤HTML代码的函数
-----------------------*/
function htmlEncode($string) {
    $string=trim($string);
    $string=str_replace("&","&",$string);
    $string=str_replace("'","'",$string);
    $string=str_replace("&","&",$string);
    $string=str_replace(""",""",$string);
    $string=str_replace("\"",""",$string);
    $string=str_replace("<","",$string);
    $string=str_replace(">",">",$string);
    $string=str_replace(" "," ",$string);
    $string=nl2br($string);
    return $string;
}
            
            
您可能感兴趣的文章:
  • 用php过滤危险html代码的函数
  • php下过滤html代码的函数 提高程序安全性
  • php HtmlReplace输入过滤安全函数
  • php 安全过滤函数代码
  • 比较好用的PHP防注入漏洞过滤函数代码
  • 几个有用的php字符串过滤,转换函数代码
  • PHP字符过滤函数去除字符串最后一个逗号(rtrim)
  • php过滤XSS攻击的函数
  • php中使用array_filter()函数过滤空数组的实现代码
  • php常用的安全过滤函数集锦
  • PHP中字符安全过滤函数使用小结
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2