Beware of double dollar sign “$$” in Your PHP Code
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!
Tags: PHP Coding Programming