In the PHP manual it clearly says that:
$foo[bar] is bad.
But is $foo[$bar] wrong too? Should I use $foo["$bar"] instead, seeing as PHP evaluates "$bar".
Thanks,
Antun
No, $foo[$bar] is not bad. The reason $foo[bar] is bad because "bar" should be a string, but it's not. The way it is now, it is considered a constant. But $bar resolves to a string, so it's fine.
Diego
On the other hand, $foo["$bar"] is bad - it's not wrong, because it works, but it means unnecessary work for PHP.