北京尚网汇智科技有限公司
您当前所在的位置:尚网汇智网站建设 > PHP技术 > 文章详细
网站建设知识
NEWS
联系我们
  • 网站建设服务电话
  • 400-883-2887
  • 公司地址:北京市昌平科技园区创意大厦2-806
  • 服务项目
    高端网站建设
    移动/微信网站建设
    手机APP开发
    OA/ERP业务系统开发
    网站维护托管
    CMS模板制作

    PHP中过滤常用标签的正则表达式

    发布时间:2014-05-29 01:22:34

    $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标签


    文章出自:北京网站建设公司-尚网汇智 https://www.net2006.com 如转载请注明出处!
    咨询服务热线
    400-883-2887
    客服电话:400-883-2887  传真:010-51654992  E-mail:support@net2006.com
    本站设计已受版权保护,任何公司及个人不得复制,违者将依法追究责任,特此声明。

    Copyright © 2005-2018 北京尚网汇智科技有限公司 版权所有 京ICP备13031271号
    查找内容: