PHP - Snippets

Aus Wikizone
Wechseln zu: Navigation, Suche

Clean up POST und GET

Zusätzliche Sicherheit für Post und Get.

function clean($elem) {
	/* used to add some security to get and post vars */
	if(!is_array($elem)) 
		$elem = htmlentities($elem,ENT_QUOTES,"UTF-8"); 
    	else 
		foreach ($elem as $key => $value) 
			$elem[$key] = $this->clean($value); 
    	return $elem; 
} 

$_CLEAN['GET'] = clean($_GET); 
$_CLEAN['POST'] = clean($_POST);