• 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标签代码方法

作者:站长图库 字体:[增加 减小] 来源:互联网 时间:2022-04-29

站长图库向大家介绍了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标签代码方法

相关文章

  • 2022-04-29#1045 无法登录 MySQL 服务器的解决方法
  • 2022-04-29去除csdn必须登录复制代码限制JS脚本
  • 2022-04-29使用CorelDRAW绘制椭圆和圆形
  • 2022-04-29DEDECMS的优化方案
  • 2022-04-29织梦dedecms网站六大SEO优化技巧分享
  • 2022-04-29如何利用CSS制作一个聚光灯效果(附代码)
  • 2022-04-29PS打造线描风格舞者壁纸平面作品设计制作教程
  • 2022-04-29Javascript怎么实现红绿灯
  • 2022-04-29Centos7如何启动与切换图形界面
  • 2022-04-29javascript在php中文乱码怎么办

文章分类

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

最近更新的内容

    • 介绍centos7 bond的配置和调试
    • 帝国cms更换php7环境后台空白
    • 宝塔面板如何屏蔽禁止某个IP(IP段)访问
    • Laravel使用redis队列实例讲解
    • PHP生成缩略图实例讲解
    • javascript:void什么意思
    • PHP怎么指定跳出几层循环
    • cdr快速制作相片锯齿边框
    • Photoshop制作漂亮火焰翅膀视频教程
    • Photoshop绘制蓝色风格的游戏手柄

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

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