php4 objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A friend of mine asked me if I knew if this was possible in PHP4.


class foo
{
    var $bar = NULL;

    function foo()
    {
        $this->bar = new bar();
    }

    function getBar()
    {
        return $this->bar;
    }

}


class bar
{
    var $thing = NULL;

    function bar()
    {
        $this->thing = "Hello World!";
    }

    function getThing()
    {
        return $this->thing;
    }

}


he wants to do something like this:

$obj =& new foo;

print $foo->getBar()->getThing();

is this possible in PHP4?

I know that he can do a:

print $obj->bar->getThing();

..but he wants it to run some stuff in the functions that he is calling
and wants to do it in one command if possible.

-Robby


-- 
/***************************************
* Robby Russell | Owner.Developer.Geek
* PLANET ARGON  | www.planetargon.com
* Portland, OR  | robby@xxxxxxxxxxxxxxx
* 503.351.4730  | blog.planetargon.com
* PHP/PostgreSQL Hosting & Development
****************************************/

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux