NYCPHP Meetup

NYPHP.org

[nycphp-talk] Question about variable variables

Chris Shiflett shiflett at php.net
Fri Feb 13 18:09:53 EST 2004


--- Eric Rank <erank at isthmus.com> wrote:
> 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;
> }

You might prefer the simplicity of this:

http://www.php.net/import_request_variables

It's definitely worth looking into.

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/



More information about the talk mailing list