top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

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

+1 vote
63 views
What is the difference between $message and $$message in PHP?
posted Dec 23, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

$message is used to store variable data. $$message can be used to store variable of a variable. Data stored in $message is fixed while data stored in $$message can be changed dynamically.

Example:

$var1 = ‘Variable 1’
$$var1= ‘variable2’

This can be interpreted as $ Variable 1=‘variable2’;

For me to print value of both variables, I will write
$var1 $($var1)

Explain the difference between $message and $$message in PHP

$message is a variable and $$message is a variable of another variable.

Example
$Message = "Query";
$Query = “Home";

echo $message //Output:- Query
echo $$message //output :-Home

$$message allows the developer to change the name of the variable dynamically.

answer Jan 3, 2018 by Manikandan J
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...