Re: referencing Superglobals with variable variables inside functions
| From: | Jason Sweat | Date: | Mon, 31 Jan 2005 18:39:51 +0000 |
| Subject: | Re: referencing Superglobals with variable variables inside functions | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-14459@lists.php.net to get a copy of this message | ||
On Mon, 31 Jan 2005 19:27:31 +0100, Michael Virnstein
<michael.virnstein@brodos.de> wrote:
> Atm it isn't possible to use a construct like $var = ${'_GET'}; inside a
> function or method. Will this behaviour change in future versions of
> PHP? I think it is somehow odd and inconsistent to not be able to use
> the superglobals that way, while it is possible outside of functions and
> methods and also with any other variable, e.g. the $HTTP_*_VARS.
> Imo it's an unnecessary restriction and will keep ppl using the old
> $HTTP_*_VARS. I also see no reason for it to stay that way and i think
> it wasn't intended by you, the developers, in the first place but turned
> out to work that way afterwards.
> So I really hope it'll change, would make much more sense. What do you
> think?
Try
$_GET['foo'] = 'bar';
function x($val, $sg) {
return $GLOBALS[$sg][$val];
}
echo x('foo','_GET');
Regards,
Jason
http://blog.casey-sweat.us/