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 to register a variable in PHP session?

520


Where session is stored?

531


Which is better wamp or xampp?

528


What is 'float' property in css?

582


Is php better than python?

547






Who is the father of php and what is the current version of php and mysql?

684


How can we display information of a variable and readable by human with php?

564


How is it possible to set an infinite execution time for php script?

515


Steps for the payment gateway processing?

547


Does jwt protect against csrf?

483


What is api laravel?

522


Can we extend multiple classes in php?

534


What is the meaning of die in php?

519


What is php and what does it do?

538


How to read a file in binary mode?

631