RE: Making a object from one class available to all objects in th e calling class
| From: | Tim Ward | Date: | Mon, 05 Feb 2001 16:13:46 +0000 |
| Subject: | RE: Making a object from one class available to all objects in th e calling class | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-38258@lists.php.net to get a copy of this message | ||
I haven't tested this, but assuming you meant an instance of class_y being
available to each instance of class_x ...
class class_x
{ var y_of_x;
function class_x() // i.e. constructor
{ $this->y_of_x = new class_y();
}
function x {
$n = new $y;
}
function z {
$n->test();
}
}
> Hi,
>
> Can someone advise on the following.
>
> class class_y
> {
> function test() {
> return "test";
> }
> }
>
> class class_x
> {
> function x {
> $n = new $y;
> }
>
> function z {
> $n->test();
> }
> }
>
> I need the object of class_y available to the other objects of classx
> but I cant figure out how I do this. Any ideas?
>
> Regards, Steve Maher
Tim Ward
Senior Systems Engineer
Please refer to the following disclaimer in respect of this message:
http://www.stivesdirect.com/e-mail-disclaimer.html