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

Does facebook use php framework?

556


Is multilevel inheritance possible in php?

502


What is php session start?

527


What is purpose of @ in Php?

658


How to check an element is exists in array or not in php?

576






What is php explain?

507


What are the different types of PHP arrays?

569


How is csrf token generated?

507


What is the use of namespace in php?

553


When a conditional statement is ended with an endif?

518


Explain the casts allowed in PHP?

583


Explain me what is the use of 'print' in php?

528


What can php do?

548


How do you pass a variable by value in php?

542


What is the difference between get and post in php?

513