Comments By: Carl
-
I find the variable composition extremely useful, for instance if you're creating a Factory - often in a Factory pattern you will need to dynamically call constructors or methods. Normally I would do it like this: $someMethodPrefix = 'populate'; $myDynamicParameter = 'MyClass'; $method = $someMethodPrefix . $myDynamicParameter; $this->$method(); // $this->populateMyClasss(); Now, I can do it in a one-liner like this: $this->{$someMethodPrefix.$myDynamicParameter}(); Thanks :)posted on Aug 20, 2007 at 4:42pm | context