Did you know? DZone has great portals for Python, Cloud, NoSQL, and HTML5!
DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Benoit has posted 48 posts at DZone. View Full User Profile

Undo_magic_quotes And PHP 6

05.25.2008
Email
Views: 994
  • submit to reddit
        

if(!function_exists('get_magic_quotes_gpc')) {
	// for PHP 6.x
	function get_magic_quotes_gpc() { return 0; }
}

if(get_magic_quotes_gpc()) {
	function undo_magic_quotes(&$array) {
		foreach($array as $key => $value) {
			if(is_array($value)) {
				undo_magic_quotes($array[$key]);
			} else {
				$array[$key] = stripslashes($value);
			}
		}
	}
	
	undo_magic_quotes($_GET);
	undo_magic_quotes($_POST);
	undo_magic_quotes($_COOKIE);
	undo_magic_quotes($_REQUEST);
	undo_magic_quotes($_FILES);
}


<a href="http://www.ab-d.fr/">Code source </a><a href="http://www.ab-d.fr/date/2008-05-25/">magic_quotes and $_GET, $_POST, $_COOKIE, $_REQUEST ( php6 )</a>