Re: Removing slashes

From: Date: Sun, 13 Apr 2003 18:17:11 +0000
Subject: Re: Removing slashes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143681@lists.php.net to get a copy of this message
> I expected the following script ADD/REMOVE the slash sign into/from > variables $A and $B. It adds but doesn't remove the slash sign. > __________________________________________ > <? > $A = addslashes($A); > $B = addslashes($B); > > echo htmlspecialchars (stripslashes($A)); > echo htmlspecialchars (stripslashes($B)); > ?> > __________________________________________ > > By using this form: [snip] If the magic_quotes_gpc php directive is on (it's on by default) then this will essentially run addslashes() on your GET, POST, and COOKIE data. Example: A form. If on and you use addslashes(), you are running addslashes twice in which case you'd have to stripslashes() twice. This is not recommended. So, either disable magic_quotes_gpc and use addslashes, or only addslashes() if get_magic_quotes_gpc() returns false, or something similar. Regards, Philip

« previous php.general (#143681) next »