Quite possibly one of PHP’s least utilized yet most valuable features is its support for Variable Variables. In short these are a method of using the value of one variable to call the name of another. Sound confusing? We'll explain everything...
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;