[thelist] PHP object property getters/setters

Scott Wehrenberg swehren at gmail.com
Fri Dec 2 11:18:28 CST 2005


Maybe I'm misunderstanding something here, but PHP5 will let you chain calls:

class Foo
{
    function Foo()
    {
        $this->bar = new Bar();
    }

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

class Bar
{
    function baz()
    {
        print 'baz';
    }
}

$foo = new Foo();

$foo->getBar()->baz();



More information about the thelist mailing list