note 51846 added to ref.info

From: Date: Tue, 12 Apr 2005 23:35:23 +0000
Subject: note 51846 added to ref.info
Groups: php.notes 
Request: Send a blank email to php-notes+get-87916@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/ref.info.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+51846 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51846&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51846&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51846&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51846&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51846&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51846&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87916) next »