Alright... say that I want to set it up so that I set a number of variables in a class (ie, $this->var1, $this->var2, etc) to something that I send in the function args of one of the class's functions. But I don't know the names of the vars that I will be setting specifically. To let me explain more, will this code work:
class myClass
{
var var1;
var var2;
var var3;
function set_vars()
{
$args=get_func_args();
reset($args);
while(list(,$var)=each($args))
{
$this->{$var}=1;
}
}
}
What I mean, is if I do this code:
<?php
$class = new myClass;
$class->set_vars('var1', 'var3');
?>
will it set $class->var1=1 and $class->var2=1 ?
--Jason