// Convert some predefined characters into HTML objects and add a backslash before the predefined characters, including single quotation marks, double quotation marks, backslash, and NULL, to protect database security
// Convert some predefined characters into html objects and add a backslash before the predefined characters, including single quotation marks, double quotation marks, backslash, and null, to protect the security of the database tutorial
Function d_htmlspecialchars ($ string ){
If (is_array ($ string )){
Foreach ($ string as $ key => $ val ){
$ String [$ key] = d_htmlspecialchars ($ val );
}
} Else {
$ String = str_replace ('&', '&', $ string );
$ String = str_replace ('"', '"', $ string );
$ String = str_replace (''', ''', $ string );
$ String = str_replace ('<', '<', $ string );
$ String = str_replace ('>', '>', $ string );
$ String = preg_replace ('/& (# d;)/', '& 1', $ string );
}
Return $ string;
}
//
Function d_addslashes ($ string, $ force = 0 ){
If (! $ Globals ['Magic _ quotes_gpc '] | $ force ){
If (is_array ($ string )){
Foreach ($ string as $ key => $ val) $ string [$ key] = d_addslashes ($ val, $ force );
}
Else $ string = addslashes ($ string );
}
Return $ string;
}