We pass onDefinition and usage
The Addslashes () function adds a backslash before the specified predefined character.
These predefined characters are:
Single quotation mark (')
Double quotation marks (")
Back slash ()
Null
Grammar
C
Parameter description
string is required. Specifies the string to check.
Hints and Notes
Tip: This function can be used to prepare the appropriate string for strings stored in the database and for database query statements.
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.
Example
In this case, we're going to add a backslash to the predefined string:
- < ? PHP
- $ Str "who ' s John Adams?" ;
- Echo $str. "This was not safe in a database query.
- <br/>";
- echo addslashes ($STR). "This is safe in a database query.";
- ?>
Output:
Who ' s John Adams? This is the not safe in a database query.
Who ' s John Adams? This is safe in a database query.
An example of using addslashes () is when you want to enter data into the database. For example, the name O ' Reilly is inserted into the database, which needs to be escaped. Most databases are used as escape characters: O ' Reilly. This allows the data to be placed in the database without inserting additional. When PHP instruction Magic_quotes_sybase is set to ON, it means that the insert ' will be used ' to escape.
By default, PHP instruction MAGIC_QUOTES_GPC is on, and it is primarily for all GET, POST, and COOKIE data automatically run Addslashes (). 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.
http://www.bkjia.com/PHPjc/446258.html www.bkjia.com true http://www.bkjia.com/PHPjc/446258.html techarticle we add a backslash before the specified predefined character by using the Addslashes () function for the definition and usage. These predefined characters are: Single quotation mark (') Double quotation mark (") backslash () NULL syntax ...