Another use for this feature in PHP is dynamic parsing..
Due to the rather odd structure of an input string I am currently parsing, I must have a reference for each particular object instantiation in the order which they were created. In addition, because of the syntax of the input string, elements of the previous object creation are required for the current one.
Normally, you won't need something this convolute. In this example, I needed to load an array with dynamically named objects - (yes, this has some basic Object Oriented programming, please bare with me..)
<?php
include("obj.class");
$object_array = array();
foreach ($input_array as $key=>$value){
$obj = "obj".$key;
$$obj = new Obj($value, $other_var);
Array_Push($object_array, $$obj);
}
?>
Now, we can use basic array manipulation to get these objects out in the particular order we need, and the objects no longer are dependant on the previous ones.
I haven't fully tested the implimentation of the objects. The scope of a variable-variable's object attributes (get all that?) is a little tough to crack. Regardless, this is another example of the manner in which the var-vars can be used with precision where tedious, extra hard-coding is the only alternative.
Then, we can easily pull everything back out again using a basic array function: foreach.
<?php
foreach($array as $key=>$object){
echo $key." -- ".$object->print_fcn()." <br/>\n";
} ?>
Through this, we can pull a dynamically named object out of the array it was stored in without actually knowing its name.