note 18190 deleted from function.get-magic-quotes-gpc by aidan
| From: | aidan@php.net | Date: | Tue, 06 Jul 2004 06:20:50 +0000 |
| Subject: | note 18190 deleted from function.get-magic-quotes-gpc by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72703@lists.php.net to get a copy of this message | ||
Note Submitter: bjartepost@hotmail.com
----
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-