First test whether magic_quotes_gpc is ON. If so, use array_map() to recursively restore the escaped data. Let's look at the simple implementation code of using stripslashes to restore the data after addslashes escape
The code is as follows
|
Copy code | ||||
if(get_magic_quotes_gpc())
{
Function stripslashes_deep($value)
{
$value = is_array($value) ? array_map('stripslashes_deep', $value) : (isset($value) ? stripslashes($value) : null);
return $value;
}
$_POST = stripslashes_deep($_POST);
$_GET = stripslashes_deep($_GET);
$_COOKIE = stripslashes_deep($_COOKIE);
}
?>