I want to make a class, classA, that contains an instance of another class, classB. This is how I've been doing it:
However, once the control leaves the constructor the newly created B object loses scope and the variable $objB is basicly pointing at nothing. I want $objB to be pointing at an instance of B at all times, such that I can access member functions and variables of B in member funcitons of A. How do I correctly do this? Thanks!
Code:
<?PHP
class B{
function B(){ //Constructor
}
}
class A{
var objB;
function A(){ //Constructor
$objB = new B();
}
}
However, once the control leaves the constructor the newly created B object loses scope and the variable $objB is basicly pointing at nothing. I want $objB to be pointing at an instance of B at all times, such that I can access member functions and variables of B in member funcitons of A. How do I correctly do this? Thanks!