600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 详细介绍PHP过滤常见html标签的正则表达式

详细介绍PHP过滤常见html标签的正则表达式

时间:2021-03-08 13:41:06

相关推荐

详细介绍PHP过滤常见html标签的正则表达式

后端开发|php教程

PHP,html,正则表达式

后端开发-php教程

PHP 用htmlentities() 函数把HTML标签转换成Html实体

access 开发源码下载,vscode如何启动编辑,ubuntu 更换tar,tomcat默认配置在哪,猪血爬虫,编辑php文件内容,seo行业还能走多远,手机版比特币交易网站源码,手机网页页面模板 html源码lzw

定义和用法

htmlentities() 函数把字符转换为 HTML 实体。

语法

php找源码,vscode中改变光标颜色,ubuntu tar还原,tomcat配置热启动,github 爬虫 代理,简易php服务器,福州效果好的seo价格,网站源码资源分享库,wordpress资源模板lzw

htmlentities(string,quotestyle,character-set)

PHP:过滤html标签的函数(这个最强大)

delphi 工资 源码,ubuntu 上向左右,tomcat是否支持重量级,python爬虫精进下载,铜川初中生php开发培训学校,站推广seolzw

PHP过滤html标签竟然有内部的函数可用,相对来说简直是太强大了。

php过滤html的函数:

strip_tags(string)

这样就可以过滤掉所有的html标签了。

如果想过滤掉除了之外的所有html标签,则可以这样写:

strip_tags(string,"");

过滤除了

xxx

之外的所有html标签,则可以这样写:

strip_tags(string,"");

PHP过滤常见html标签的正则表达式

php 项目开发中,经常要用到一些过滤html标签的正则表达式,收藏一下备用:

$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("/(.*?)

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