Class instantiation within another class?
| From: | Thomas Reinke | Date: | Sat, 17 Jun 2000 02:10:05 +0000 |
| Subject: | Class instantiation within another class? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-2115@lists.php.net to get a copy of this message | ||
Can anyone point out the problem with this logic:
include class#1
include class#2
$class1 = new class1;
$class1->method();
And within class1's "method" call, it does a
"$class2 = new class2"
I've not been able to get this to work, and am wondering
if there is a fundamental limitation to making use of
one class from within another. Essentially, I don't
think it is recognizing the 2nd class, and this shows
up when i attempt to do a "class2->method()" call.
(Says no such beast exists). If, on the other hand,
I instantiate both classes first, and then pass class2
as a parameter to class1 in the constructor, I have no
problem accessing class2's methods...
I'd thought it was something perhaps with the "global"
declaration, but haven't been able to figure out how
to "global"ly declare the class itself, prior to
instantiation.
Any ideas?
Thomas