Re: extract($_POST)

From: Date: Wed, 23 Oct 2002 11:38:59 +0000
Subject: Re: extract($_POST)
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-121064@lists.php.net to get a copy of this message
Here's something fancy i have wrote once. you might as well use it embedded into a function passing the array of keys to export. It does not export() your variables, it simply MOVES it into the right places so things like SESSIONS will still work and get registered. Not a prefect one, it was optimized for my own needs. <? // Alter variables for the versions prior to 4.1.0 // NOTE: $_REQUEST global variable is NOT supported. if(strnatcasecmp('4.1.0', PHP_VERSION)>=0) { foreach(Array( '_GET' => 'HTTP_GET_VARS' ,'_POST' => 'HTTP_POST_VARS' ,'_COOKIE' => 'HTTP_COOKIE_VARS' ,'_SESSION' => 'HTTP_SESSION_VARS' ,'_SERVER' => 'HTTP_SERVER_VARS' ,'_ENV' => 'HTTP_ENV_VARS' ,'_FILES' => 'HTTP_POST_FILES' ) as $transvar['new']=>$transvar['old']) { if(isset($$transvar['old']) and is_array($$transvar['old'])) { $GLOBALS[$transvar['new']] = &$$transvar['old']; } } // Unset transvar, we do not need it anymore. unset($transvar); } ?> --- Maxim Maletsky maxim@php.net www.PHPBeginner.com // PHP for Beginners www.maxim.cx // my Home // my Wish List: ( Get me something! ) http://www.amazon.com/exec/obidos/registry/2IXE7SMI5EDI3 <ed@home.homes2see.com> wrote... : > > > That's not possible. I don't know how to explain it technically, but > > when you submit the form, your data is passed to an instance of the > > processing script and the script runs. Even if a dozen instances are all > > running at once, each only operates on the data that was passed to it by > > the user pressing submit. > > > > What are you "storing"?? > > I will be using sessions to keep things such as a user id while the end > user is traversing from page to page but I wasn't sure that it would make > sense to also store variable values as well in the session while they are > needed then drop them from the session when they are not. As long as each > process is secure enough to keep one person from getting another person's > values then it should be secure enough to use the extract($_POST) method > as opposed to using the $_POST['var'] method. It just seems that it would > be more effective to get all the values at once instead of writting out > every instance of $_POST['var'] for each individual 'var'. > > Thanks, > > Ed > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#121064) next »