note 18190 added to function.get-magic-quotes-gpc
| From: | bjartepost at hotmail dot com | Date: | Mon, 14 Jan 2002 01:38:25 +0000 |
| Subject: | note 18190 added to function.get-magic-quotes-gpc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-24786@lists.php.net to get a copy of this message | ||
Here's another nifty snippet of code that strips slashes from GPC-variables. This one is
optimized for PHP 4.1.x, using foreach() and the new global GPC variables.
if (get_magic_quotes_gpc()) {
foreach($_GET as $k=>$v) $_GET["$k"]=stripslashes($v);
foreach($_POST as $k=>$v) $_POST["$k"]=stripslashes($v);
foreach($_COOKIE as $k=>$v) $_COOKIE["$k"]=stripslashes($v);
}
Also remember to use htmlentities() before inserting these variables into form <input> values.
Otherwise unexpected behaviour may (or most certainly will) occur if these variables contain quotes.
-Bjarte-
--
http://www.php.net/manual/en/function.get-magic-quotes-gpc.php
http://master.php.net/manage/user-notes.php?action=edit+18190
http://master.php.net/manage/user-notes.php?action=delete+18190
http://master.php.net/manage/user-notes.php?action=reject+18190