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:
$name = "John";
$$name = "Registered user";
print $John;<span class="fullpost">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.
Tidak ada komentar:
Posting Komentar