PHP magic function application details. PHP provides two magic reference functions for reference data: magic_quotes_gpc and magic_quotes_runtime. when the ini parameter is set to ON, two magic reference functions magic_quotes_gpc and magic_quotes_runtime are provided for the referenced PHP parameter. when the ini is set to ON, the quoted data will be subject to single quotation marks and double quotation marks, and the backslash is automatically added to the backslash to help us automatically translate the symbols, make sure that the data operation runs correctly. However, in different php versions or server configurations, some magic_quotes_gpc and magic_quotes_runtime are set to on, while others are off, therefore, the program we write must meet the on and off conditions. So what are the differences between magic_quotes_gpc and magic_quotes_runtime functions? See the following description:
Magic_quotes_gpc
Scope of Application: WEB client server;
Time: request start, for example, when the script is running.
Magic_quotes_runtime
Scope: obtained from the data read from the file, the exec () execution result, or the SQL query;
Time: each time the script accesses the data generated in the running state.
Therefore, the value of magic_quotes_gpc will affect the data obtained through Get/Post/Cookies. The value of magic_quotes_runtime will affect the data read from the file or the data queried from the database.
Example:
<Form action = "" method = "post"> STR: <input type = "text" name = "str"> <input type = "submit"> </form> <? Php/* fill in the form: '"these symbols. if magic_quotes_gpc is not enabled, they will not be escaped by backslash */echo'. the values passed through POST are: ', $ _ POST ['str'],' <br/> '; if (get_magic_quotes_gpc () {// check whether magic_quotes_gpc is enabled. if not, escape with addslashes $ str =$ _ POST ['str'];} else {$ str = addslashes ($ _ POST ['str']);} echo 'escaped here: ', $ str,' |
The most important difference is the two points mentioned above: they are different in processing objects.
The value of magic_quotes_gpc affects the data obtained through Get/Post/Cookies.
The value of magic_quotes_runtime will affect the data read from the file or the data queried from the database.
Here are a few functions that you want to associate:
Set_magic_quotes_runtime ():
Set magic_quotes_runtime value. 0 = Close. 1 = open. the default status is disabled. you can use echo phpinfo () to view magic_quotes_runtime
Get_magic_quotes_gpc ():
View the value of magic_quotes_gpc. 0 = Close. 1 = open.
Get_magic_quotes_runtime ():
View the value of magic_quotes_runtime. 0 = Close. 1 = open.
Note that the value of magic_quotes_gpc () cannot be set in the program.
...