I'd have expected ${$b} to be 'a' but it is 'b', why is this the case?
$a = "b";
$b = "a";
Sorry again I forgot to put ${$b} produces "b"
I'd have expected ${$b} to be 'a' but it is 'b', why is this the case?
$a = "b";
$b = "a";
Sorry again I forgot to put ${$b} produces "b"
Only thing I can think of is that when you're getting its value you forgot the $. This is a pretty common typo for new php programmers (and even for experienced ones that program in other languages).
If you use the ${$b} it is equal to $a. So that time it will print "b" only.
It makes sense now with your addition
Sorry again I forgot to put ${$b} produces "b"
that works as intended: You are using $b (containing "a") as a variable name. So as the end result, you are querying $a.
The variable variable expression ${$b} takes the value of $b for the variable name. So ${$b} evaluates to ${"a"} that is equivalent to $a that then evaluates to "b".