Forum Moderators: coopster
class MyClass
{
var $attr1;var $attr2
function setAttr($var, $val)
{
$this->{$var} = $val;
}
}$thisClass = new MyClass;
$settings = array('attr1' => 'A string',
'attr2' => 1);
foreach ($settings as $key=>$val)
{
$thisClass->setAttr($key, $val);
}
It works fine for integers, but not for strings?
I'd also like to use the same method to construct dynamic function and class names... Can anyone help me out with the proper syntax to use?