Most of the time when we are doing stripslashes and addslashes it is on data that may be using the magic_quotes_gpc. Such data is put in $_GET, $_POST, $_COOKIE and may need to have slashes added or slashes stripped. The following are two functions that helps with this, by checking the magic_quotes_gpc first:

Fri, 06/03/2005 - 12:29pm
Well I guess it doesn't like having tags wrapped in the area :-/ So here they are again...
/**
* Adds slashes, first checks for magic quotes gpc.
*
* @access public
* @param string $str
* @return string
**/
function gpc_addslashes($str){
if (!get_magic_quotes_gpc()) {
return addslashes($str);
}
return $str;
}
/**
* Strips slashes, first checks for magic quotes gpc
* @access public
* @param string $str
* @return string
**/
function gpc_stripslashes($str){
if (get_magic_quotes_gpc()) {
return stripslashes($str);
}
return $str;
}
parent | login to post comments »