var1, var2, var3 isn't the only pattern where this feature is useful. What if was varA, varB, varC .... or what if you wanted to call one of many methods that differed by a predictable pattern like this? We have other things besides 'for' loops in which a variable variable, or variable function, or variable class name could be used inside of. Would still love to see the example of setting 150 variables without using variable variables. Even the foreach loop would require using them as far as I can see. So you use a foreach loop..
Code: Select all
foreach($this as $variableName => $variableValue )
{
// now what ?
}
I don't see what there is not to get, PCSpectra, from how you re-phrased my point you get it just fine. Maybe you have a factory method that needs to accept as an argument a class name that will be instantiated, for that there is variable class names. There is a use case for all this stuff, like I always say programmer's don't just generally build stuff to confuse people. Each feature of the language has a useful application.
Of course you wouldn't write code willingly that uses them. Its a tool for a certain scenario, when you have quite a few different variables you need to set that are named according to a predictable pattern. Its for when the code you're extending is crap (or just not easy to extend).