Press "Enter" to skip to content

What is $ v/s $$ in PHP

0
You have think or searched that what is $ and $$, if yes then, your search end here.

$$var  is known as reference variable where as $var is normal variable, in the same way program can create the variable name it can create any other string.

Let us take a example to understand:-

 <?php 
           $var = “Sonu”;
           $$var = “Monu”;
           echo $var;
           echo $$var;
           echo $Sonu;
 ?>

Output:-

Sonu
Monu
Monu

Here $var variable just only print its value Sonu, $$var is a reference it uses the value of a variable whose name is the value of $var so it’s print its value Monu

That’s all guys for more post related to Web development please like my facebook page and other social networks.

How to install Django on Windows step by step guide
What is the difference's between print and echo in php?