-
-
//----saddslashes - function daddslashes($string, $force = 0, $strip = FALSE) {
- //Is the string or array forced? Remove
- //If magic reference is not turned on or $force is not 0
- if(!MAGIC_QUOTES_GPC || $force) {
- if(is_array($string)) { //If it is an array, loop this function
- foreach ($string as $key => $val) {
- $string[$key] = daddslashes($val, $force);
- }
- } else {
- //If magic references are on or $force is 0
- / /The following is a ternary operator. If $strip is true, execute stripslashes to remove the backslash character, and then execute addslashes
- //$strip is true, that is, remove the backslash character first and then escape it as $ _GET, $_POST, $_COOKIE and $_REQUEST The $_REQUEST array contains the values of the first three arrays
- //Why do we need to remove the backslash and then escape the $string here, because sometimes $string may have Two backslashes, stripslashes filters out excess backslashes
- $string = addslashes($strip ? stripslashes($string) : $string);
- }
- }
- return $string;
- }
//------saddslashes
- function saddslashes($string) { if(!MAGIC_QUOTES_GPC){
- if(is_array($string)) { //If the escape is an array, then the array Recursively escape the value in
- foreach($string as $key => $val) {
- $string[$key] = saddslashes($val);
- }
- } else {
- $string = addslashes($string ); //Escape single quotes ('), double quotes ("), backslashes () and NUL (NULL characters)
- }
- return $string;
- }else{
- return $string;
- }
- ?>
-
Copy the code
The key point is:
saddslashes can escape every data:
-
- function saddslashes($string) {
- if(is_array($string)) {
- foreach($string as $key => $val) {
- $string[$key] = saddslashes($val);
- }
- } else {
- $string = addslashes($string);
- }
- return $string;
- }
- ?>
Copy code
|