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.
$$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”.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok