Using Variable Variables in PHP - Variable Variables with Classes (
Page 5 of 7 )
Variable Variables work equally well with class objects, the basic
syntax of which is almost the same as the use of variable variables with
functions. Set the class name into a variable, call the variable variable of
that variable and you then have access to variables within that class. Here’s an
example:
class Eric {
var $foo = "bar";
}
$Eric = new Eric;
$v = "Eric";
echo $$v->foo;
the output of which would be:
bar