Hi there, I was wondering if someone could help me with a problem I'm having with referencing a class. Lets say I have a class "A", and inside that class I create an array of objects defined by class "B". When I create a class "A" object, how do I use the functions in class "B". Here is an example to show what I mean ...
class B {
var $mID;
//Constructor:
function B($ID) {
$this->mID = $ID;
}
function get_ID() {
return $this->mID;
}
}
class A {
var $BArray;
function A() {
$BArray = array();
}
function addB($ID) {
$BArray[] = new B($ID);
}
}
now I want to do ...
$objA = new A(); //works
$objA->addB(89); // works
echo "My new B id is ".$A->B[0]->get_ID(); //doesn't work