chinmay.sahoo
New member
An extremely useful feature of PHP is that you can access variables by using indirect references, or to put it simply, you can create and access variables by name at runtime.
Consider the following example:
This code results in the printing of" Registered user ." The bold line uses an additional $ to access the variable with name specified by the value of $name ("John" ) and changing its value to "Registered user". Therefore, a variable called $John is created.
You can use as many levels of indirections as you want by adding additional $ signs in front of a variable
Consider the following example:
$name = "John";
$$name = "Registered user";
print $John;
This code results in the printing of" Registered user ." The bold line uses an additional $ to access the variable with name specified by the value of $name ("John" ) and changing its value to "Registered user". Therefore, a variable called $John is created.
You can use as many levels of indirections as you want by adding additional $ signs in front of a variable