Variable variables again!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Variable variables again!

Post by spacebiscuit »

I began programming in PHP 12 years ago and I just cannot get my head around variable variables:

Does anyone know why this is causing an error:

Code: Select all

echo"$_GET[toedit{"${z}"}]";
The variable names are toedit1, toedit2 etc!

Thanks,

Rob.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: Variable variables again!

Post by mikosiko »

Code: Select all

echo"$_GET[toedit{"${z}"}]";
looks like incorrect " usage to me
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Variable variables again!

Post by Eran »

This is not variable variable, it's a simple string.

Code: Select all

echo $_GET['toedit' . $z];
Post Reply