What is difference between $message And $$message? in PHP

Recommended Answers

All 3 Replies

Please Do Google for very better and clear answer.

Lets take into account the following code.

$message="This is a string<br>";
echo $message;

$variable="This is the second string";
echo $$message;

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

What is difference between $message And $$message? in PHP

All variables in PHP start with a '$' sign symbol.

echo $($var);

exactly it works like mathematical substitute functionality.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.