In PHP, both $ and $$ are used to access variables, but they have different meanings
1. $ (Single Dollar Sign):
It is used to access the value of a single variable.
Example:
$name = "John";
echo $name; // Output: John
2. $$ (Double Dollar Sign):
- It is used to access a variable whose name is stored in another variable.
- It's also known as variable variable or dynamic variable.
Example:
$name = "John";
$$name = "Doe"; // Creates a variable $John with value "Doe"
echo $John; // Output: Doe