100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > php过滤HTML标签 属性等正则表达式汇总【PHP】

php过滤HTML标签 属性等正则表达式汇总【PHP】

时间:2022-11-23 23:03:32

相关推荐

php过滤HTML标签 属性等正则表达式汇总【PHP】

后端开发|php教程

php,过滤HTML,正则表达式

后端开发-php教程

棋盘网站源码,ubuntu下svn配置,tomcat6 跨域问题,新浪标题爬虫,php接口慢 的排查思路,亚洲seo优化lzw

$str=preg_replace("/\s+/", " ", $str); //过滤多余回车$str=preg_replace("/<[ ]+/si","<",$str); //过滤<__("<"号后面带空格) $str=preg_replace("//si","",$str); //注释$str=preg_replace("//si","",$str); //过滤DOCTYPE$str=preg_replace("//si","",$str); //过滤html标签$str=preg_replace("//si","",$str); //过滤head标签$str=preg_replace("//si","",$str); //过滤meta标签$str=preg_replace("//si","",$str); //过滤body标签$str=preg_replace("//si","",$str); //过滤link标签$str=preg_replace("//si","",$str); //过滤form标签$str=preg_replace("/cookie/si","COOKIE",$str); //过滤COOKIE标签 $str=preg_replace("/(.*?)/si","",$str); //过滤applet标签$str=preg_replace("//si","",$str); //过滤applet标签 $str=preg_replace("/(.*?)/si","",$str); //过滤style标签$str=preg_replace("//si","",$str); //过滤style标签 $str=preg_replace("/(.*?)/si","",$str); //过滤title标签$str=preg_replace("//si","",$str); //过滤title标签 $str=preg_replace("/(.*?)/si","",$str); //过滤object标签$str=preg_replace("//si","",$str); //过滤object标签 $str=preg_replace("/(.*?)/si","",$str); //过滤noframes标签$str=preg_replace("//si","",$str); //过滤noframes标签 $str=preg_replace("/(.*?)/si","",$str); //过滤frame标签$str=preg_replace("//si","",$str); //过滤frame标签 $str=preg_replace("/(.*?)/si","",$str); //过滤script标签$str=preg_replace("//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标签,如javAsCript:alert(

清除空格,换行

phpmyadmin配置本地源码,ubuntu如何更换主题,爬虫写文献综述,php985211,ecshop优化seolzw

function DeleteHtml($str){$str = trim($str);$str = strip_tags($str,"");$str = ereg_replace("\t","",$str);$str = ereg_replace("\r\n","",$str);$str = ereg_replace("\r","",$str);$str = ereg_replace("\n","",$str);$str = ereg_replace(" "," ",$str);return trim($str);}

过滤HTML属性

二手车 源码下载,vscode编辑64位程序,xbmc ubuntu,tomcat 线程不释放, 调用 sqlite,网页设计技术重点,joomla会员注册与数据库连接,服务器搭建站点是否需要iis配置php环境才能访问php动态页面,多说插件好用吗,前端word框架,爬虫查询车票,php系统信息,seo书籍推荐,Springboot过时了,aspcms 标签小工具, 企业网站源码下载,网页向导jquery,登录模板下载,网站建设后台,网页导航栏页面代码,志愿服务管理系统源代码,建宗亲网站程序源码免费下载lzw

1,过滤所有html标签的正则表达式:

]+>

//过滤所有html标签的属性的正则表达式:

$html = preg_replace("/]*>/","",$html);

3,过滤部分html标签的正则表达式的排除式(比如排除

,即不过滤

):

]+>

4,过滤部分html标签的正则表达式的枚举式(比如需要过滤

等):

]*>

5,过滤部分html标签的属性的正则表达式的排除式(比如排除alt属性,即不过滤alt属性):

\s(?!alt)[a-zA-Z]+=[^\s]*

6,过滤部分html标签的属性的正则表达式的枚举式(比如alt属性):

(\s)alt=[^\s]*

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。