Apr 27 2010

Always remove slashes from GET and POST

Category: PhpGiulio Pons @ 10:41 am

This is a small piece of code that I use since many years. It removes all slashes from $_GET and $_POST arrays if magic quote parameter is setted. Sometimes is usefull, put it at the beginning of your scripts…

if (get_magic_quotes_gpc()) {

	function slashes($e) { if (is_array($e)) return array_map("slashes", $e); else return stripslashes($e); }
	if (isset ($_POST) && count($_POST)) $_POST = array_map("slashes", $_POST);
	if (isset ($_GET) && count($_GET)) $_GET = array_map("slashes", $_GET);

}
Share

Related posts:

  1. Recursive remove directory (RMDIR) in PHP

Leave a Reply