DEV Community

Imran Hossain (Rubab)
Imran Hossain (Rubab)

Posted on • Updated on

Beware of double dollar sign "$$" in a variable in PHP.

We all know Dollar sign($) is used to declare a variable in PHP. What if we accidentally type dollar sign two times for a variable. This can potentially affect your expected output.

For example, let's say we want to encrypt data. The output of the encrypted data will not be the same for variables with single dollar variable ($x) and double dollar variable ($$x) because the $$x (double dollar) is a reference variable. This reference variable is called variable variables in PHP. Variable variables are simply variables whose names are dynamically created by another variable’s value.

So, we also need to check this kind of mistake while debugging our code if the logic of the code seems alright.

Happy bug finding!


Thank you for reading my article. You can join code with rubab for web development-related queries & discussions.

Also, you can find me on:

Linkedin For Regular Posts

My website

My Facebook Page

My Youtube Channel

Top comments (0)