During development, we should pay attention to preventing SQL injection. Therefore, we must process the values submitted in the form to update the data to the database.
Php functions. Any value can be passed for conversion.
Copy codeThe Code is as follows:
Function quotes ($ content)
{
// If magic_quotes_gpc = Off, start processing
If (! Get_magic_quotes_gpc ()){
// Determine whether $ content is an array
If (is_array ($ content )){
// If $ content is an array, it will process every single
Foreach ($ content as $ key => $ value ){
$ Content [$ key] = addslashes ($ value );
}
} Else {
// If $ content is not an array, it will be processed only once.
Addslashes ($ content );
}
} Else {
// If magic_quotes_gpc = On, it will not be processed
}
// Returns $ content
Return $ content;
Use stripslashes () to remove the backslash.
Stripslashes (), which can automatically add (backslash) \ Remove When addslashes () is processed