Re: Making a object from one class available to all objects in the calling class
| From: | szii at sziisoft dot com | Date: | Mon, 05 Feb 2001 17:02:32 +0000 |
| Subject: | Re: Making a object from one class available to all objects in the calling class | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-38264@lists.php.net to get a copy of this message | ||
IMHO, I'd use
class class_y
{
function test()
{
return "test";
}
}
class class_x
{
$var m_SomeOtherClass;
function x()
{
$this->m_SomeOtherClass = new class_y;
}
function z()
{
$this->m_SomeOtherClass->test();
}
}
AFAIK, there's no real way to "embed" a class definition
within another class definition. Not quite sure why you'd
want to, either, but it's your code. =)
'Luck!
-Szii
At 02:52 PM 2/5/2001 +0000, Stephen Maher wrote:
>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
>