PHP provides two magic reference functions to facilitate our reference data MAGIC_QUOTES_GPC and Magic_quotes_runtime, both of which will encounter single quotes ' and double quotes ' and backslashes for the data we reference if the php.ini is set to ON is automatically with a backslash, help us to automatically translate the symbol, to ensure the correct operation of data operations, but we have different versions of PHP or different server configuration, some MAGIC_QUOTES_GPC and magic_quotes_runtime set to ON, and some are off, So the program we write must conform to both on and off two cases. So what's the difference between the two functions of MAGIC_QUOTES_GPC and Magic_quotes_runtime? Look at the following instructions:
MAGIC_QUOTES_GPC
The scope of action is: Web customer service side;
Action time: The start of the request is, for example, when the script is running.
Magic_quotes_runtime
Scope: Data read from a file or executed by exec () or from a SQL query;
Action time: Data generated each time the script accesses the running state.
So the MAGIC_QUOTES_GPC setting will affect the data obtained through Get/post/cookies, and the Magic_quotes_runtime setting will affect the data read from the file or the data that is queried from the database.
Example Description:
<form action= "" method= "post" >str:<input type= "text" name= "STR" ><input type= "submit" > </form> <?php/* we fill in the form: ' "these Symbols, if the MAGIC_QUOTES_GPC is not turned on, then they will not be escaped by a backslash */echo ' now the value passed through POST is: ', $_post[' str '], ' <br/> '; if (GET_MAGIC_QUOTES_GPC () {//Check if MAGIC_QUOTES_GPC is open, escape with addslashes if not open $str = $_post[' str '];} else {$str = addslashes ($_post[' str ');} Echo ' Here is escaped: ', $str, ' http://www.bkjia.com/PHPjc/446683.html www.bkjia.com true http://www.bkjia.com/PHPjc/446683.html techarticle PHP provides two magic reference functions to facilitate our reference data MAGIC_QUOTES_GPC and magic_quotes_runtime, these two functions if the php.ini is set to ON, the number we reference ...
|