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
https://forums.phpfreaks.com/topic/36591-varable-varable-help-cheers/
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.