PHP anti-injection function (formatting data ). Copy the code as follows :? Format data (prevent injection) functionsite_addslashes ($ string, $ force0 ){! Defined (MAGIC_QUOTES_GPC) define (MAGIC_QUOTES_GPC, get_magic_q
The code is as follows:
// Format the data (to prevent injection)
Function site_addslashes ($ string, $ force = 0 ){
! Defined ('Magic _ QUOTES_GPC ') & define ('Magic _ QUOTES_GPC', get_magic_quotes_gpc ());
If (! MAGIC_QUOTES_GPC | $ force ){
If (is_array ($ string )){
Foreach ($ string as $ key => $ val ){
$ String [$ key] = daddslashes ($ val, $ force );
}
} Else {
$ String = addslashes ($ string );
}
}
Return $ string;
}
?>
The http://www.bkjia.com/PHPjc/324024.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/324024.htmlTechArticle code is as follows :? // Format data (prevent injection) function site_addslashes ($ string, $ force = 0 ){! Defined ('Magic _ QUOTES_GPC ') define ('Magic _ QUOTES_GPC', get_magic_q...