Remove slashes added by magic_quotes_gpc





17
Date Submitted Thu. Jul. 27th, 2006 4:51 AM
Revision 1 of 1
Helper rastersize
Tags PHP | quotes
Comments 1 comments
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.

// 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);
}
 

Aron C

jiart.org/
-----------------------
http://jiart.org/
My digital playground with it's own sandbox.
Well anyway, I love programming

Comments

Comments magic_quotes_sybase
Sun. Oct. 29th, 2006 12:57 PM    Scripter SCoon

Voting