Dev Expert Dev Expert - 1 year ago 74
PHP Question

PHP ${$?} Could someone shed some light?

I'm touching up on some PHP that I sometimes forget (keep the old brain going) and came across this in a PHP questionnaire. It goes as follows:

$a = "b";
$b = "a";

print ${$b} ;
//$b = "b"

How does this work and how would I use it practically? Thank you in advance.

Answer Source

This is a variable variable

print ${$b} 

It first evaluates {$b} and gets 'a'. So then it evaluates $a and gets "b" (the value stores in $a).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download