Re: Re: support for useful language structures

From: Date: Sun, 29 Jul 2001 17:34:05 +0000
Subject: Re: Re: support for useful language structures
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-1127@lists.php.net to get a copy of this message
At 17:07 2001-07-29 +0000, you wrote:
azatoth@hem.passagen.se (Erik Hjortsberg) wrote in news:5.0.2.1.0.20010729135915.01d24cf0@pop.student.lu.se: $foo::Bar(); Why do you need this syntax? Why call a static method on a specific class? Why not just write Foo::Bar()?
Bacause if you use a subclass and use a static method as a factory. I.e.: <code> class Foo {
        var $className = 'Foo';
...
        function &clone() {
                return $this->className::Get($this->id);
        }
...
        function &Get($id) {
                return new Foo($id);
        }
} class Bar extends Foo {
        var $className = 'Bar';
...
        function &Get($id) {
                return new Bar($id);
        }
} $foo = &Foo::Get(1); $fooClone = &$foo->clone(); $bar = &Bar::Get(1); $barClone = &$bar->clone(); </code> (In Get() one would put initializing checks or whatever.) /erik hjortsberg

« previous php.pear.dev (#1127) next »