php 过滤掉html标签及标签内的所有内容
2016-10-19 11:53
471 查看
$str=preg_replace("/\s+/", " ", $str); //过滤多余回车 $str=preg_replace("/<[ ]+/si","<",$str); //过滤<__("<"号后面带空格) $str=preg_replace("/<\!–.*?–>/si","",$str); //注释 $str=preg_replace("/<(\!.*?)>/si","",$str); //过滤DOCTYPE $str=preg_replace("/<(\/?html.*?)>/si","",$str); //过滤html标签 $str=preg_replace("/<(\/?head.*?)>/si","",$str); //过滤head标签 $str=preg_replace("/<(\/?meta.*?)>/si","",$str); //过滤meta标签 $str=preg_replace("/<(\/?body.*?)>/si","",$str); //过滤body标签 $str=preg_replace("/<(\/?link.*?)>/si","",$str); //过滤link标签 $str=preg_replace("/<(\/?form.*?)>/si","",$str); //过滤form标签 $str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签 $str=preg_replace("/<(applet.*?)>(.*?)<(\/applet.*?)>/si","",$str); //过滤applet标签 $str=preg_replace("/<(\/?applet.*?)>/si","",$str); //过滤applet标签 $str=preg_replace("/<(style.*?)>(.*?)<(\/style.*?)>/si","",$str); //过滤style标签 $str=preg_replace("/<(\/?style.*?)>/si","",$str); //过滤style标签 $str=preg_replace("/<(title.*?)>(.*?)<(\/title.*?)>/si","",$str); //过滤title标签 $str=preg_replace("/<(\/?title.*?)>/si","",$str); //过滤title标签 $str=preg_replace("/<(object.*?)>(.*?)<(\/object.*?)>/si","",$str); //过滤object标签 $str=preg_replace("/<(\/?objec.*?)>/si","",$str); //过滤object标签 $str=preg_replace("/<(noframes.*?)>(.*?)<(\/noframes.*?)>/si","",$str); //过滤noframes标签 $str=preg_replace("/<(\/?noframes.*?)>/si","",$str); //过滤noframes标签 $str=preg_replace("/<(i?frame.*?)>(.*?)<(\/i?frame.*?)>/si","",$str); //过滤frame标签 $str=preg_replace("/<(\/?i?frame.*?)>/si","",$str); //过滤frame标签 $str=preg_replace("/<(script.*?)>(.*?)<(\/script.*?)>/si","",$str); //过滤script标签 $str=preg_replace("/<(\/?script.*?)>/si","",$str); //过滤script标签 $str=preg_replace("/javascript/si","Javascript",$str); //过滤script标签 $str=preg_replace("/vbscript/si","Vbscript",$str); //过滤script标签 $str=preg_replace("/on([a-z]+)\s*=/si","On\\1=",$str); //过滤script标签 $str=preg_replace("//si","&#",$str); //过滤script标签
相关文章推荐
- php读取富文本编辑器编辑后的文章内容,并去除所有html标签、空格以及空白,截取字符串(包括中文)
- php教程过滤所有html标签的几种方法
- PHP 过滤HTML中除了img标签外其它所有标签
- PHP实现网页内容html标签补全和过滤的方法小结【2种方法】
- php过滤html标签截取部分内容
- php截取指定字符之间内容的类与实例(含转码、过滤html等)
- PHP 取消所有的HTML标签
- php 过滤html标签的函数代码
- PHP过滤各种HTML标签的表达式,值得收藏
- Asp.Net中过滤所有的Html标签
- 怎么用PHP正则 去掉所有html标签的属性部分
- 去掉内容中的所有html标签
- php获取网页标题和内容函数(不包含html标签)
- 过滤到所有HTML 标签
- asp.net正则表达式提取网页网址、标题、图片实例以及过滤所有HTML标签实例
- 通过js去掉所有的html标签,得到HTML标签中的所有内容
- php完全过滤HTML,JS,CSS等标签
- php完全过滤HTML,JS,CSS等标签
- 去掉内容中的所有全部html标签。