Learn $ (Single Dollar ) and $$ (Double Dollar)

$variable (Single Dollar): This is a normal variable to store the values like string,float,integer etc.

$$variable (Double Dollar) : This reference variable keep the value of $variable  as a variable name .

To know more See this Example:

<?php  
$a = "vardata";  
$$a= 10;  
echo $a."</br>";  
echo $$a."</br>";  
echo $vardata;  
?>  

 
Output:
vardata
10
10

Next Example:

<?php  
 $a="Akshay";  
$$a="Dhiman";  
echo $a. "</br>";  
echo $$a. "</br>";  
echo "Last name of $a is " . $$a;  
?>  

 

Output:
Akshay
Dhiman
Last Name of Akshay is Dhiman

In above example we again did the same , we assign the value Akshay in variable $a and reference variable $$a assigned as Dhiman.




Last Updated: 2018-07-06 12:32:44 By akshay

SHARE THIS

share_facebook share_twitter share_google_plus

Please Comment Here :