note 51846 deleted from ref.info by philip

From: Date: Wed, 29 Mar 2006 18:50:57 +0000
Subject: note 51846 deleted from ref.info by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106956@lists.php.net to get a copy of this message
Note Submitter: epost at danieloskarsson dot se ---- If you are having troube with unwanted slashes and you can't turn off magic_quotes_gpc in php.ini for some reasons. Then you can reverse the changes with the following script from http://www.sitepoint.com/forums/showpost.php?p=396899 <?php function strip_magic_quotes($arr) { foreach ($arr as $k => $v) { if (is_array($v)) { $arr[$k] = strip_magic_quotes($v); } else { $arr[$k] = stripslashes($v); } } return $arr; } if (get_magic_quotes_gpc()) { if (!empty($_GET)) { $_GET = strip_magic_quotes($_GET); } if (!empty($_POST)) { $_POST = strip_magic_quotes($_POST); } if (!empty($_COOKIE)) { $_COOKIE = strip_magic_quotes($_COOKIE); } } ?> This worked fine for me fixing what stripslashes() couldn't. The problem was that stripslashes() removed legacy added slashes from my PHP-code which I recieved from the POST-array. With the above function only the slashes added by magic_quotes_gpc() is removed.

« previous php.notes (#106956) next »