PHP Filter Common Tags

Source: Internet
Author: User
Tags script tag

<?php$str=preg_replace ("/\s+/",  " ",  $str);  //Filter Excess carriage return $str=preg_replace ("/<[ ]+/ Si "," < ", $str);  //filter <__ (with spaces behind" < ") $str =preg_replace ("/<\!–.*?–>/si "," ", $str)  //comment $str =preg_replace ("/< (\!. *?) >/si "," ", $str);  //filter Doctype$str=preg_replace ("/< (\/?html.*?) >/si "," ", $str);  //Filter HTML tag $str=preg_replace ("/< (\/?br.*?) >/si "," ", $str);  //filter br label $str=preg_replace ("/< (\/?head.*?) >/si "," ", $str);  //Filter head tag $str=preg_replace ("/< (\/?meta.*?) >/si "," ", $str);  //filter meta tag $str=preg_replace ("/< (\/?body.*?) >/si "," ", $str);  //Filter Body tag $str=preg_replace ("/< (\/?link.*?) >/si "," ", $str);  //Filter Link Tag $str=preg_replace ("/< (\/?form.*?) >/si "," ", $str);  //Filter Form label $str=preg_replace ("/cookie/si "," Cookie ", $str);  //Filter Cookie Tag $str=preg_ Replace ("/< (applet.*?)" > (. *?) < (\/applet.*?) >/si "," ", $str);  //Filter Applet label $str=preg_replace ("/< (\/?applet.*?) >/si "," ", $str);  //Filter AppletLabel $str=preg_replace ("/< (style.*?) > (. *?) < (\/style.*?) >/si "," ", $str);  //filter style tag $str=preg_replace ("/< (\/?style.*?) >/si "," ", $str);  //filter style tag $str=preg_replace ("/< (title.*?) > (. *?) < (\/title.*?) >/si "," ", $str);  //Filter title Tag $str=preg_replace ("/< (\/?title.*?) >/si "," ", $str);  //Filter title Tag $str=preg_replace ("/< (object.*?) > (. *?) < (\/object.*?) >/si "," ", $str);  //filter the OBJECT tag $str=preg_replace ("/< (\/?objec.*?) >/si "," ", $str);  //filter the OBJECT tag $str=preg_replace ("/< (noframes.*?) > (. *?) < (\/noframes.*?) >/si "," ", $str);  //Filter noframes label $str=preg_replace ("/< (\/?noframes.*?) >/si "," ", $str);  //Filter noframes label $str=preg_replace ("/< (i?frame.*?) > (. *?) < (\/i?frame.*?) >/si "," ", $str);  //Filter Frame label $str=preg_replace ("/< (\/?i?frame.*?) >/si "," ", $str);  //Filter Frame label $str=preg_replace ("/< (script.*?) > (. *?) < (\/script.*?) >/si "," ", $str);  //Filter Script tag $str=preg_replace ("/< (\/?script.*?) >/si ", "", $str);  //Filter Script tag $str=preg_replace ("/javascript/si", "JavaScript", $str);  //Filter Script Tag $str=preg_ Replace ("/vbscript/si", "VBScript", $str),  //filter script tag $str=preg_replace ("/on ([a-z]+) \s*=/si", "on\\1=", $str );  //Filter Script tag $str=preg_replace ("/&#/si", "the", "$str);  //Filter Script Tag,?>


PHP Filter Common Tags

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.