Forum Moderators: coopster
class B{
var $id;
var $name;
function B($id, $name){
// necessary initialisation
}
}[/PHP]
Case:
I would like to set objects as:
[PHP]$objA->setObject(new B(1, "x"));
$objA->setObject(new B(2, "y"));[/PHP]
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.
class A { // I know I have swapped around your classes, its just so that B extends A
var $id;
var $name;
function A($id, $name){
// necessary initialisation
}
class B extends class A {
var $obj_array = array();
function B($id, $name) {
$this->A($id, $name);
}
If $this->A doesnt work then try -
parent::A
A::A