redarrow Posted February 1, 2007 Share Posted February 1, 2007 Advance thank you. Hi all i am learning varable varable now as what i can see but dont no, If i am correct the consept is that a set varable name can also be used as another set varable with the same set varable name? please give more examples and am i correct cheers. <?php // set a varable john to 32 $john=32; //set varable to name john $name="john"; //echo out varable name as john then varable varable echo age echo "My name is $name and my age is ${$name}"; ?> i sort of get the concept but what will it acheve in programming in php cheers. Quote Link to comment Share on other sites More sharing options...
.josh Posted February 1, 2007 Share Posted February 1, 2007 well, what's the principle behind variables? Variables abstract data. Variable variables are the same principle, but taken one step further. Variable variables abstract variable names. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 1, 2007 Author Share Posted February 1, 2007 can u kindly give a small snippet exaple plesae thank u more understanding now cheers. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 1, 2007 Share Posted February 1, 2007 ... Your example is a "small snippet." Quote Link to comment Share on other sites More sharing options...
.josh Posted February 1, 2007 Share Posted February 1, 2007 well, the manual has some examples... Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 i never really used it. its all a bit confusing to me. it could end up becoming to confusing. Quote Link to comment Share on other sites More sharing options...
redarrow Posted February 1, 2007 Author Share Posted February 1, 2007 That my point about varable varable to confusing but unfortuntly it in the php exam so i need also to learn it but i agree. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted February 1, 2007 Share Posted February 1, 2007 dang. although from reading the manual it does seem alright, but i dont really see the point. if you left your code for a while then came back you'd be buggered. variables jumping all over the place. Quote Link to comment Share on other sites More sharing options...
.josh Posted February 1, 2007 Share Posted February 1, 2007 LoL, it's not really THAT hard... I mean, you use variables to push data all over the place and manipulate it etc... in the first place. It really is the same concept. It is good for things where you don't necessarily know what all of the variables would be. Like for instance, making a configuration file for your program...kind of like php.ini, actually. Turning certain flags/options on/off will create/not create x amount of variables with whatever names. You wouldn't want to waste the memory by creating variables you aren't going to use, would you? But you don't know what the user will turn on/off. That's where variable variables come in. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.