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

Answer Posted / seema

$message is a simple variable and $$message is variable of a
variable(also known as dynamic variable).

For Example:

$message = "welcome";
$welcome = "to php programming tricks!!!";


echo $message; // Output: welcome

echo "<br>",$$message; // Output: to php programming tricks!!!

You will notice with the second echo it will check the
variable $message for it's value and it's value is the
string "welcome". So then it searches for $welcome and finds
the final value which it yields.

Is This Answer Correct ?    12 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is the comparison of objects done in php?

523


How can we define a variable accessible in functions of a php script?

553


How to merge values of two arrays into a single array?

487


Can you define an argument as a reference type?

558


sort term descripttion form, report and uery

1657






Is server side a session?

498


How to close a session properly?

534


What are the different tables(engine) present in mysql, which one is default?

518


What is a helper function?

548


How do you debug php?

564


Is it possible to use com component in php?

556


Tell me are parent constructors called implicitly inside a class constructor?

546


What is form action php?

591


How many types of php frameworks are there?

493


Is it possible to destroy a cookie?

544