In PHP, there are two functions that are related to the escape of a string, they are addslashes and stripslashes respectively.
Addslashes ($string) to add a backslash (\) before the specified predefined character to prepare the appropriate string for the string stored in the database and for the database query statement.
Note: By default, PHP instruction MAGIC_QUOTES_GPC is on, and automatically runs Addslashes () for all GET, POST, and COOKIE data. Do not use Addslashes () for strings that have been MAGIC_QUOTES_GPC escaped, because this results in double-layer escaping. You can use the function GET_MAGIC_QUOTES_GPC () to detect this situation.
Stripslashes ($string), which is the inverse of addslashes (), is used to remove the backslash added by the addslashes () function to restore the escaped character, also known as reversal semantics, primarily for cleaning up data retrieved from a database or HTML form.
So what characters will addslashes be escaped, as follows:
Single quotation mark (')
Double quotation marks (")
Back slash (\)
Null
In addition, a string with a single quote delimiter, supports two escape characters:
Single quotation mark (')
Back slash (\)
A string with a double quote delimiter that supports the following escapes:
\ n line break (LF or ASCII characters 0x0A (10))
\ r Enter (CR or ASCII character 0x0D (13))
\ t Horizontal tab (HT or ASCII character 0x09 (9))
\ \ Backslash
\$ dollar Sign
\ "Double quotation marks
\[0-7]{1,3} This regular expression sequence matches a character represented by an octal symbol
\x[0-9a-fa-f]{1,2} This regular expression sequence matches a character that is represented by a hexadecimal symbol
Articles you may be interested in
- PHP string substitution function str_replace faster than preg_replace
- String processing function in PHP (string Functions) Full summary
- PHP Performance Optimizations: Use Isset () to determine string length faster than strlen ()
- Escape,encodeuri,encodeuricomponent comparison and analysis of JavaScript's string encoding function
- Some of the powerful string handling functions that PHP has forgotten
- PHP Filter String functions
- PHP's most accurate string-length intercept function
- PHP generates consecutive numbers (Letters) array function range () analysis, PHP lottery program function
http://www.bkjia.com/PHPjc/764092.html www.bkjia.com true http://www.bkjia.com/PHPjc/764092.html techarticle in PHP, there are two functions that are related to the escape of a string, they are addslashes and stripslashes respectively. Addslashes ($string), add a backslash (\) before the specified predefined character, with ...