In this tutorial, we will learn about the difference between the $variable and $$variable.
In the above example, $a and $b both are simple variables where $a is an integer variable and $b is a string variable you can easily access the value of this variable.
The $$var_name is known as a reference variable where $var_name is a normal variable. The $$var_name used to refer to the variable with the name as the value of the variable $var_name.
In the above example, $$fruit is a reference of $fruit, where $fruit is a simple variable that can hold anything like integer, string, float, etc. But $$fruit is a reference variable that stores the variable $fruit.
In this case, $fruit is a variable that stores the value “apple” and $apple is another variable that holds the value “sweet”. When the program executes $fruit replace with the $apple. If you print the $fruit then the value will be “apple” and when you print $$fruit that means $apple ($fruit is replaced by the apple) and the value will be “sweet”.