$type = new Zend_Form_Element_Select('type',array('onchange' => 'alert("working")'));
Month: November 2013
using PHP Values as Variable names and to call Functions
This should apply to perl as well:
Variable name:
$myvar = 'foo';
${$myvar} = 'haswell';
echo $foo
RESULT
'haswell'
Call a function:
$type = 'red';
$myClass->$type(); == $myClass->red();
More helpful stuff:
${"variableName"} = 12;
{"functionName"}();
$className->{"variableName"};
$className->{"methodName"}();
StaticClass::${"variableName"};
StaticClass::{"methodName"}();
Are there any other Languages that can do this, I know Perl Can...
And What is this ability called?
Please Leave a commment if you have more information.
Loop Through an Associative Array PHP
foreach (array_expression as $key => $value) {
echo $key;
}