On Fri, 2004-02-13 at 11:38, Joshua Beall wrote: > I want to turn off magic quotes. I realize in retrospect that using a > .htaccess file to turn magic quotes would probably be better than this code, > and I am going to switch to that solution, but I am still trying > to figure out what is causing my current problem:
Having a function to undo magic quotes can be very useful if you distribute your application. Here is what I use, just call disable_magic_quotes(). It should not do any damage if magic_quotes is already disabled. /* Undo damage caused by magic quotes */ function remove_magic_quotes($vars,$suffix = '') { eval("\$vars_val =& \$GLOBALS['$vars']$suffix;"); if (is_array($vars_val)) { foreach ($vars_val as $key => $val) { remove_magic_quotes($vars, $suffix . "['$key']"); } } else if (!is_object($vars_val)) { $vars_val = stripslashes($vars_val); eval("\$GLOBALS['$vars']$suffix = \$vars_val;"); } } // Defeat magic quotes function disable_magic_quotes() { if (get_magic_quotes_gpc()) { remove_magic_quotes('_GET'); remove_magic_quotes('_POST'); remove_magic_quotes('_COOKIE'); ini_set('magic_quotes_gpc',0); } set_magic_quotes_runtime(0); } -- Adam Bregenzer [EMAIL PROTECTED] http://adam.bregenzer.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php