Remove slashes added by magic_quotes_gpc
17
The recursive function stripslashesDeep($value) will (upon called) strip slashes (\) from strings and arrays (even arrays with arrays within themself). The controlstatement (if) checks if magic quotes gpc is on, if it is we strip the slashes it have added.
Very good snippet if you want to have the "same" input even if you switch to an enviroment where magic quotes gpc is set to something else than on your originall server.
Very good snippet if you want to have the "same" input even if you switch to an enviroment where magic quotes gpc is set to something else than on your originall server.
// stripslashes function (the deep method)
function stripslashesDeep($value)
{
return (is_array($value) ? array_map('stripslashesDeep', $value) : stripslashes($value));
}
// If get magic quotes gpc is turned on we de strip the data!
if (get_magic_quotes_gpc() == true)
{
$_GET = stripslashesDeep($_GET);
$_POST = stripslashesDeep($_POST);
$_COOKIE = stripslashesDeep($_COOKIE);
}
Comments
Voting
Votes Up
ASmith
bertheymans
ColdKeyboard
ctiggerf
dannyboy
i_kenneth
kryptx
lolfejs
mceppi
Neverwolf
Pio
RatNuShock
schmalls
SecondV
Sonsam
sundaramkumar
wiz1705






"Note: If the directive magic_quotes_sybase is ON it will completely override magic_quotes_gpc. So even when get_magic_quotes_gpc() returns TRUE neither double quotes, backslashes or NUL's will be escaped. Only single quotes will be escaped.''