Skip to content
doubtly

2 answers

$message is a normal variable; $$message is a variable variable: it uses the value of $message as the name of another variable.

<?php
$message = "greeting";
$$message = "Good morning";   // creates $greeting = "Good morning"

echo $message;     // greeting
echo $$message;    // Good morning
echo $greeting;    // Good morning
?>

Here $message holds the string "greeting". Writing $$message means "the variable whose name is the value of $message", that is $greeting. So the name of the second variable is decided at run time. Both are ordinary variables whose values can change; the difference is only that $$message refers to a variable indirectly by name.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.