Jump to content

varable varable help cheers.


redarrow

Recommended Posts

 

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.