Do some two development projects, database, file encoding can not be large-scale modification, such as two times to develop a Japanese system, encoding is ja16sjis,$_post or $_get information if "Application", the information will become "Shen", more than a backslash!
Put out the solution first, add the following code where needed or in the configuration file
if (GET_MAGIC_QUOTES_GPC ()) {
function Stripslashes_deep ($value)
{
$value = Is_array ($value)?
Array_map (' Stripslashes_deep ', $value):
Stripslashes ($value);
return $value;
}
$_post = Array_map (' Stripslashes_deep ', $_post);
$_get = Array_map (' Stripslashes_deep ', $_get);
$_cookie = Array_map (' Stripslashes_deep ', $_cookie);
}
Network Collation Related:
Check, it seems can set php.ini in the Magic_quotes_runtime
In the PHP configuration file, there is a Boolean setting, that is magic_quotes_runtime, when it is opened,
Most of PHP's functions automatically add an overflow character to an externally introduced (including database or file) data with an inverse
Slash. Of course, if you repeat the multibyte backslash for the overflow character, there will be multiple backslashes in the string, so
Set up and detect with Set_magic_quotes_runtime () and Get_magic_quotes_runtime () php.ini
The Magic_quotes_runtime state in the file. To make your program work regardless of the server's settings
Perform. You can use Get_magic_quotes_runtime to detect the state of the setting at the beginning of the program to determine whether to manually process
, or use Set_magic_quotes_runtime (0) to turn off the setting at the beginning (or when no automatic escaping is required).
MAGIC_QUOTES_GPC set whether the "\" \ \ "\" in the data from GPC (Get,post,cookie) is automatically inverted
Line. System settings can be detected with GET_MAGIC_QUOTES_GPC (). If this setting is not turned on, you can use the
Addslashes () function is added, its function is to the database query statements and so on need to precede some characters with anti-
Slash. These characters are single quotation marks (\ '), double quotation marks (\ "), backslashes (\ \), and NUL (the NULL character).
The general usage is as follows;
if (!GET_MAGIC_QUOTES_GPC ())
{
Addslashes ($prot);
}
PHP post get traditional, Japanese, Korean automatically add backslash problem