RE: [PHP] Removing slashes
| From: | John W. Holmes | Date: | Sun, 13 Apr 2003 18:16:30 +0000 |
| Subject: | RE: [PHP] Removing slashes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143682@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));
> ?>
If magic_quotes_gpc is enabled in your php.ini, then the values will
already be escaped with slashes. Running addslashes() again will double
escape them. So when you run stripslashes(), you're only removing one
set of slashes.
---John W. Holmes...
PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/