note 86852 modified in control-structures.if by danbrown

From: Date: Thu, 06 Nov 2008 17:40:29 +0000
Subject: note 86852 modified in control-structures.if by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-146243@lists.php.net to get a copy of this message
Here is a way to declare global variable variables using a function. This particular example handles an array that contains names of $_POST items. This is to avoid the notices that php gives when checking an unused $_POST. <?php function check ($inputs) { foreach ($inputs as $input) { global $$input; $$input = isset($_POST[$input]) ? $_POST[$input] : ""; } } ?> --was-- Here is a way to declare global variable variables using a function. This particular example handles an array that contains names of $_POST items. This is to avoid the notices that php gives when checking an unused $_POST. function check ($inputs) { foreach ($inputs as $input) { global $$input; $$input = isset($_POST[$input]) ? $_POST[$input] : ""; } } http://php.net/manual/en/control-structures.if.php

« previous php.notes (#146243) next »