Add a backslash (php removes the backslash) before the PHP quotes.
- $ Str = $ _ POST ["str"]; // read the str content and assign it to the $ str variable.
- If (get_magic_quotes_gpc () {// if get_magic_quotes_gpc () is enabled
- $ Str = stripslashes ($ str); // process the string
- }
Three methods to solve this problem are described below: 1. modify the PHP configuration file php. ini. this method is only applicable when 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 );
- }
|