Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What is difference between $x and $$x

Answer Posted / deepesh mehta

This type of variable diclearation is called "Variable
variables".
Sometimes it is convenient to be able to have variable
variable names. That is, a variable name which can be set
and used dynamically. A normal variable is set with a
statement such as:

$x = 'hello';

A variable variable takes the value of a variable and
treats that as the name of a variable. In the above
example, hello, can be used as the name of a variable by
using two dollar signs. i.e.

$$x = 'world';

At this point two variables have been defined and stored in
the PHP symbol tree: $a with contents "hello" and $hello
with contents "world". Therefore, this statement

echo "$x ${$x}";

produces the exact same output as:

echo "$a $hello";

i.e. they both produce: hello world.

Is This Answer Correct ?    34 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain $_FILES Superglobal Array?

984


Explain me what is the difference between $_files['userfile']['name'] and $_files['userfile']['tmp_name']?

868


What is difference between Method overriding and overloading in PHP?

1002


What is the difference between for and foreach?

1048


Which is the correct way to check if a session has already been started ?

937


Why does php start with variables?

970


What is a trait in php?

978


What are the functions for imap?

1061


Explain what does the expression exception::__tostring means?

819


What are the advantages of indexes?

870


How to execute a function in php?

899


How to stop the execution of php script?

928


How can I convert ereg expressions to preg in php?

940


What is the default session time in php?

963


What is the difference between $var and $$var?

1017