In the PHP page, if you don't want the following to happen:
Single quotes are escaped to \ '
Double quotes are escaped to \ "
Then you can set the following to prevent:
Method One: Set in php.ini: MAGIC_QUOTES_GPC = Off
Method Two: $str =stripcslashes ($STR)
Add
1. In the case of PHP magic_quotes_gpc=on,
Example
The code is as follows |
Copy Code |
<?php $str =$_post[' str ']; if (!GET_MAGIC_QUOTES_GPC ()) {//First judgment not open $newStr =addslashes ($STR);//Then filter with addslashes function } ?> |
We can not make string data for input and output databases
Addslashes () and Stripslashes (), the data is also displayed correctly.
If you addslashes () the input data at this time,
Then you must use Stripslashes () in the output to remove the extra backslash.
2. For PHP Magic_quotes_gpc=off
You must use Addslashes () to process the input data, but you do not need to use stripslashes () to format the output
Because Addslashes () did not write the backslash to the database, it only helped MySQL complete the execution of the SQL statement