How does php filter post and get sensitive data in batches
This article mainly introduces "how php filters post and get sensitive data in batches". In daily operation, I believe many people have doubts about how php batch filters post and get sensitive data. Xiaobian consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the questions of "how php batch filters post and get sensitive data". Next, please follow the editor to study!
Function code:
The copy code is as follows:
/ / php batch filter post,get sensitive data
If (get_magic_quotes_gpc ()) {
$_ GET = stripslashes_array ($_ GET)
$_ POST = stripslashes_array ($_ POST)
}
Function stripslashes_array (& $array) {
While (list ($key,$var) = each ($array)) {
If ($key! = 'argc' & & $key! =' argv' & & (strtoupper ($key)! = $key | | '.intval ($key) = = "$key") {) {
If (is_string ($var)) {
$array [$key] = stripslashes ($var)
}
If (is_array ($var)) {
$array [$key] = stripslashes_array ($var)
}
}
}
Return $array
}
/ / filter
Function htmlencode ($str) {
If (empty ($str)) return
If ($str== "") return $str
$str=trim ($str)
$str=str_replace ("&", $str)
$str=str_replace (">", $str)
$str=str_replace ("", $str)
$str=str_replace (",", $str)
$str = str_replace ("", ">", $str)
$str=str_replace ("