Dev Expert Dev Expert - 10 months ago 39
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.


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).