NYCPHP Meetup

NYPHP.org

[nycphp-talk] Question about variable variables

Eric Rank erank at isthmus.com
Fri Feb 13 16:40:34 EST 2004


On old pages built requiring 'register globals' to be on, I use these lines
for a quick fix when migrating to a system where register globals is off. Is
it right? Well, it might not be the best practice. Is it wrong? I DO feel
like I'm cheating when using it, but you can't beat the simplicity.

//first make the $_GET variables
foreach($_GET as $var=>$val){
    $$var = $val;
}
//$_POST variables override the $_GET variables
foreach($_POST as $var=>$val){
    $$var = $val;
}


Eric


----- Original Message ----- 
From: "Chris Shiflett" <shiflett at php.net>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Friday, February 13, 2004 3:25 PM
Subject: Re: [nycphp-talk] Question about variable variables


> --- Daniel Porcher <danporcher at earthlink.net> wrote:
> > Is there a consensus about the use of variable variables?
>
> I don't think so. I know a lot of people who think it is bad practice.
> Their reasoning is never technical; it's social. They argue that variable
> variables are more likely to confuse another programmer who looks at your
> code, sort of like when you cram too many operations on a single line.
>
> In my opinion, there are situations where it just happens to be the most
> elegant solution. But, I certainly feel outnumbered on this one. :-)
>
> Chris
>
> =====
> Chris Shiflett - http://shiflett.org/
>
> PHP Security - O'Reilly
>      Coming mid-2004
> HTTP Developer's Handbook - Sams
>      http://httphandbook.org/
> PHP Community Site
>      http://phpcommunity.org/
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list