note 105335 modified in reserved.variables.get by danbrown

From: Date: Wed, 10 Aug 2011 15:48:03 +0000
Subject: note 105335 modified in reserved.variables.get by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-182397@lists.php.net to get a copy of this message
I don't directly use $_GET due to security concerns, instead I create a new array called $_CLEAN which contains cleaned superglobal variables. <?php function clean($elem) { 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); ?> I also do this for $_POST, as followed: <?php $_CLEAN['POST'] = clean($_POST); ?> --was-- I don't directly use $_GET due to security concerns, instead I create a new array called $_CLEAN which contains cleaned superglobal variables. function clean($elem) { 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); I also do this for $_POST, as followed: $_CLEAN['POST'] = clean($_POST); http://php.net/manual/en/reserved.variables.get.php

« previous php.notes (#182397) next »