Content filtering is to prevent some security injection or cross-domain operation, let's take a look at some of my simple anti-injection content filtering program code, I hope the article will help you classmates.
Method One, filter out some useless content
Filter useless information is more rigorous, useful may also input not to go in, you can find other filtering methods on the Internet:
The code is as follows |
Copy Code |
function checkhtml ($data) { $ret = Preg_match ("/[".,:; *?~ '!@#$%^&+=) (<>{}]|]| [|/|\|"|| /", $data); if ($ret = = 1) { return false; Exit } else { return true; } } |
Example 2 Filter Some HTML tags
The code is as follows |
Copy Code |
Function uh ($STR) { $farr = Array ( "/s+/",//filter Extra blanks "/< (/?) (scripti?framestylehtmlbodytitlelinkmeta?%) ([^>]*?) >/isu ",//filter"; echo "Back"; Exit } } echo "What you have entered is:". $str; } ?>
Test whether the filter takes effect:
|
http://www.bkjia.com/PHPjc/632820.html www.bkjia.com true http://www.bkjia.com/PHPjc/632820.html techarticle content filtering is to prevent some security injection or cross-domain operation, let's take a look at my collation of a few simple anti-injection content filtering program code, I hope the article on the ...