-
-
- $str=$_POST["str"]; //Read the content of str and assign it to the $str variable
- if(get_magic_quotes_gpc()){ //If get_magic_quotes_gpc() is turned on
- $str=stripslashes($str); //Process the string
- }
Copy the code
The following introduces three methods to solve this problem:
1. Modify the PHP configuration file php.ini
This method is only suitable if you have the right to manage the server. If you use virtual space, you can only use the last two methods.
In the PHP configuration file php.ini, set magic_quotes_gpc, magic_quotes_runtime, and magic_quotes_sybase to off.
As follows:
-
-
- if(get_magic_quotes_gpc()){
- function stripslashes_deep($value){
- $value=is_array($value)?array_map('stripslashes_deep',$value):stripslashes($value );
- return $value;
- }
- $_POST=array_map('stripslashes_deep',$_POST);
- $_GET=array_map('stripslashes_deep',$_GET);
- $_COOKIE=array_map('stripslashes_deep',$_COOKIE) ;
- $_REQUEST=array_map('stripslashes_deep',$_REQUEST);
- }
Copy code
|