how to avoid collision of objects ??
Posted: Wed Apr 02, 2008 5:26 am
Hello forums!!
Suppose we had the following classes:
Case:
I would like to set objects as:
My Question:
How to make the property $obj_array to hold the class objects of B with unique id.
Thanks in advance for the kind help.
Suppose we had the following classes:
Code: Select all
class A{
var $obj_array = array();
function setObject($classB_obj){
$this->obj_array[] = $classB_obj
}
}
class B{
var $id;
var $name;
function B($id, $name){
// necessary initialisation
}
}I would like to set objects as:
Code: Select all
$objA->setObject(new B(1, "x"));
$objA->setObject(new B(2, "y"));How to make the property $obj_array to hold the class objects of B with unique id.
Thanks in advance for the kind help.