Re: Creating local vars from HTTP Post Array

From: Date: Fri, 17 Oct 2003 10:37:19 +0000
Subject: Re: Creating local vars from HTTP Post Array
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166441@lists.php.net to get a copy of this message
On Fri, 17 Oct 2003 10:11:57 +0000, you wrote: >I'm re-coding a fairly large multi step form which was written with PHP's >register globals turned on. Since upgrading PHP this form has stopped >working and needs editting. > >Rather than manually changing each var - > >$foo to $_POST['foo'] > >(there are simply too many) i'd like to do something like this - > >while(list($key, $val) = each($_POST)) eval("\$.$key = >stripslashes($value)"); > >using a loop to create local variables for each variable in the HTTP Post >array. foreach ($_POST as $key => $value) { $$key = $value; } Something like that should work. But it's equivalent to turning RG on, so why not just do that? Nothing's going to explode, it's just a language feature.

« previous php.general (#166441) next »