• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • dedecms
  • ecshop
  • z-blog
  • UcHome
  • UCenter
  • drupal
  • WordPress
  • 帝国cms
  • phpcms
  • 动易cms
  • phpwind
  • discuz
  • 科汛cms
  • 风讯cms
  • 建站教程
  • 运营技巧
您的位置:首页 > CMS教程 >建站教程 > PHP过滤HTML标签代码方法

PHP过滤HTML标签代码方法

作者:站长图库 字体:[增加 减小] 来源:互联网

站长图库向大家介绍了PHP过滤HTML标签,PHP过滤代码等相关知识,希望对您有所帮助

过滤指定标签大全

$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标签,如javAsCript:alert(


清除空格,换行

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

过滤所有HTML标签的正则表达式:

</?[^>]+>

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

$html = preg_replace("/<([a-zA-Z]+)[^>]*>/","<\\1>",$html);


分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • PHP过滤HTML标签代码方法

相关文章

  • 揭秘Photoshop图层样式与蒙版的一些技巧
  • Alexa工具条真的能够提升Alexa排名吗?
  • Photoshop制作个性时尚的立体字教程
  • nginx报错502怎么办?解决方案分享
  • Photoshop详细解析斜面浮雕和等高线原理
  • vue3为什么快?vue3的效率提升主要在哪方面?
  • WordPress自动设置标签Tag自动内链无插件实现方法
  • PhotoShop设计简洁清新的小按钮制作教程
  • 手把手教你CSS如何实现毛玻璃效果
  • 关于最新版ThinkORM对于时间字段的调整

文章分类

  • dedecms
  • ecshop
  • z-blog
  • UcHome
  • UCenter
  • drupal
  • WordPress
  • 帝国cms
  • phpcms
  • 动易cms
  • phpwind
  • discuz
  • 科汛cms
  • 风讯cms
  • 建站教程
  • 运营技巧

最近更新的内容

    • LayUI如何导入excel文件
    • Laravel $kernel->handle 报错的解决办法
    • 百度小程序富文本解析工具bdParse的使用
    • PS鼠绘清纯可爱的古装卡通小女孩
    • 面试官:列举几种PHP拓展的实现手段及其性能比较?
    • MySQL中 IN和NOT IN用法详解
    • Dedecms5.7如何将系统的data目录迁移到web以外目录
    • Thinkphp3.2 畅言评论回推接口制作
    • JS判断当前浏览器是否是微信端
    • Photoshop制作绿色风格金属立体字教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有