Configure get_magic_quotes_gpc in php to prevent SQL injection usage
Get_magic_quotes_gpc (); is to obtain the value of the php environment variable magic_quotes_gpc. If the value is 1, it indicates that the configuration is enabled; if it is 0, it indicates that the configuration is disabled!
-
Get_magic_quotes_gpc (); the value is 1, indicating that it is enabled. Php automatically adds the Escape Character "" to the parameter values passed by POST, GET, and COOKIE to ensure the security of the data. This especially prevents SQL injection.
-
Get_magic_quotes_gpc (); the value is 0, indicating that it is disabled. The php parser does not automatically add the Escape Character "" to the parameter values passed by POST, GET, or COOKIE. Then, the addslashes function is used to escape the parameter.
-
Get_magic_quotes_gpc (); Disabled. Use the addslashes function to filter parameters to prevent injection. Example:
<? Php
$ Str = $ _ POST ['str'];
If (! Get_magic_quotes_gpc () {// first, judge whether the function is enabled.
$ NewStr = addslashes ($ str); // use the addslashes function to filter
}
?>