I need to create an instance of class B in the constructor of class A. class B depends on a variable that is passed along when I create the class A instance. Problem is that no matter how many different instances of class A I have, they only create and use the same instance of class B, since the creation of that instnce is hardcoded so to speak in the class A constructor. Make sense? Here's code:
-----INDEX.PHP ------
...
$classA_instance1 = new ClassA($classB_variable1);
$classA_instance2 = new ClassA($classB_variable2);
...
-----CLASS A----------
// constructor
...
$classB_instance = new ClassB($classB_variable)
...
// the last line here is the problem. on the first instance creation in index.php ($classA_instamce1), I create a class B instance here using $classB_variable1. But when I create the new instance ($classA_instance2) the new classB instance overwrites the first one. I do not want to rearrange the classes into one or have to create classB instances anywhere but within class A. How can I create a unique instane of class B? Hope this makes sense...
Thanks
Jadow