How can I dynamically pass "items" to class function?
For example here it is a piece of some class and its function where I declare an element of object (items) as $b:
//..........
public function __add2SomeObj($b) {
$namespc = $this -> __someObj(); // __someObj() returns object
$namespc -> cats = $b;
}
//...................
Can I pass any other name instead cats
dynamically so it won't be declared as a string?
i.e. something like:
//..........
public function __add2SomeObj($a,$b) {
$namespc = $this -> __someObj(); // __someObj() returns object
$namespc -> $a = $b;
}
//...................
} //end of class started above
$t=new aboveClass()
$t->__add2SomeObj("cats", array(1=>"PussyCat",2=>"Scratchy"));
$t->__add2SomeObj("dogs", array(1=>"Waffy",2=>"Sharik")); // once again but dogs...
Should I define a constant or what to make this or should i declare this protected varibale as object like (object) $vaaar
?
Sorry I'm a little bit infamiliar with PHP OOP...