Setter problem
Posted: Tue Apr 06, 2004 9:41 am
I was writing my setter method for a class and came across to write:
The thing is I wonder when If I need to set a variable value to 0. Then the $newvalue would come as 0 and checking with empty would return false.
Any ideas?
Thanks,
-Nay
Code: Select all
function setVar($varname, $newvalue) {
// return(void)
// $varname = The name of a variable to be changed
// $newvalue = The new value for the variable
if( emtpy($varname) || empty($newvalue) || !isset($this->class->$newvalue) ) {
// If given arguments are empty, or the variable name does not exist
return false;
} else {
$this->object->$varname = $newvalue;
return true;
}
}Any ideas?
Thanks,
-Nay