Difference between $ and $$ in PHP

Today we check the difference between single dollar ($) and double dollar ($$).

Here is a most confusing question that, what is the Difference between dollar and double dollar in PHPWe all know that in PHP programming $ is used for declaring variables or when we write a variable name in PHP, use $ before that name.

Difference between Dollar and Double Dollar in PHP

First thing, in the single dollar ($) stored data is fixed while in the double dollar ($$) is changed dynamically. Variable means are changeable. With explanation variables are those things which are changeable on time.

$var: represnts a variable

$$var (variable’s variable): represents a varibale with the content of $var

Now we check the major difference between $ and $$ with the help of an example below,

Example Difference between Dollar and Double Dollar in PHP

Use our PHP ONLINE EDITOR

Output: PHCODERTECH

Difference between $ and $$ in PHP

Explanation of the single dollar ($) and double dollar ($$) Example

$$var2 => $($var2) => $var => PHPCODERTECH

The double dollar is a very useful feature of PHP where you can use for assign variable value dynamically.

Check Also:

Create Dynamically Generated Text File and Download Using JavaScript

Happy Coding..!

Was this article helpful?
YesNo

By Bikash

My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH. I am a web Programmer by profession and working on more than 50 projects to date. Currently I am working on the web-based project and all the CMS and frameworks which are based on PHP.

Leave a Reply

Your email address will not be published. Required fields are marked *