Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


What is difference between $x and $$x

Answers were Sorted based on User's Feedback



What is difference between $x and $$x..

Answer / 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

What is difference between $x and $$x..

Answer / chinuku

$var is a variable and $$variable is a Reference or Dynamic
variable
ex:$var="test";
$test="php";
<?php
echo $var;
echo $$var;
?>
ans
$var=test;
$$var=php;

Is This Answer Correct ?    21 Yes 4 No

What is difference between $x and $$x..

Answer / muzic

$x is a simple variable whereas $$x is a reference variable.

Is This Answer Correct ?    17 Yes 4 No

What is difference between $x and $$x..

Answer / psharma05

$x is a simple variable where $$x means value of $x becomes other variable.
eg.
$x="hello";
$$x="hi";
echo $hello;

output will be:
hi

Is This Answer Correct ?    11 Yes 5 No

What is difference between $x and $$x..

Answer / khan

Visit http://filesharepoint.com To Download free Scripts
books and many more just click the link below
<a
href='http://filesharepoint.com'>http://filesharepoint.com</a>

Is This Answer Correct ?    0 Yes 7 No

Post New Answer



More PHP Interview Questions

How do you check if a variable has been set in php?

0 Answers  


What is the use of htmlentities in php?

0 Answers  


What is RSS?How to use it in Program?

3 Answers  


What types of images that PHP supports?

2 Answers  


List out some tools through which we can draw E-R diagrams for mysql.

2 Answers  






What is an example of a variable?

0 Answers  


What can I do by cakePHP?

4 Answers  


How can I retrieve values from one database server and store them in other database server using PHP?

1 Answers  


How do I see how many pages per session in google analytics?

0 Answers  


What is cookies php?

0 Answers  


What is varchar mysql?

0 Answers  


Are react hooks stable?

0 Answers  






Categories