Re: Class::__construct() vs. $this->__construct()

From: Date: Thu, 31 Mar 2005 00:39:15 +0000
Subject: Re: Class::__construct() vs. $this->__construct()
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-37013@lists.php.net to get a copy of this message
Joe Stump wrote:
What would the difference between: $this->__construct(); and Class::__construct() be? I'm asking in regards to making my PHP4 classes "forward thinking" in regards to an upgrade to PHP5. I'd like the code to nicely run in both PHP4 and PHP5 and I've seen it done both ways. Is there a difference? class Foo extends Bar {
    function Foo()
    {
        Foo::__construct(); // Or should it be $this->__construct();
    }
    function __construct()
    {
        parent::__construct();
    }
} Thoughts? --Joe
Use $this->__construct() in the PHP 4 class constructor only. By Calling "Foo::__construct()" you're calling a static method, unrelated to the current instance. "parent::" is magic so the scope remains within the current instance. -Philippe

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