The Addslashes () function returns a string that adds a backslash before a predefined character.
The predefined characters are:
- Single quotation mark (')
- Double quotation marks (")
- Back slash (\)
- Null
Echo "Who's Bill Gates?<br>"echo addslashes("Who's Bill Gates?")
Results:
Who '
The second automatically adds a backslash in front of the single quotation mark. If the string is in storage, there are single quotes inside it, and SQL injection may be used for security purposes.
Note: By default, PHP automatically runs Addslashes () for all GET, POST, and COOKIE data. So you should not use Addslashes () for a string that has been escaped, because this results in double-layer escaping. You can use the function GET_MAGIC_QUOTES_GPC () to detect this situation.
1. Ini_set (MAGIC_QUOTES_GPC) Gets the configuration information for MAGIC_QUOTES_GPC, if this value is True
All ' (single quotes), "(double quotes), \ (backslash), and NUL ' s are automatically escaped by a backslash.
For example, the data you received on the table dropdowns submission Xiaoming's dog server is Xiaoming\ 's dog
2. Stripslashes dereference A reference string it's going to go.
The stripslashes function in PHP means that the backslash character in the string is removed, and if there are two consecutive backslashes, only one is removed; the example is as follows:
Echo stripslashes ("Hello everybody, here is \" "Baidu Quiz platform \"!) "); // output: Hello everyone, here is "Baidu Quiz platform"!
Addslashes and Stripslashes functions