A great yet widely unused element of variable variables is their ability to be employed with functions. The function name can be set within a variable and then run through calling the variable variable of that variable. Here’s an example:
Here’s a quick example of this in action, building on the same program segment I had introduced variable variables with:
This code would output:
as the echo statement is printing the value of the variable that gets created from the resultant of the value() function, "Eric". As we have already set $$x (which, following the variable variable, is the same as $Eric) to "Seufert", the same value is outputted, only this time resulting from a function call.
blog comments powered by Disqus |