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

From: Date: Thu, 31 Mar 2005 16:47:05 +0000
Subject: Re: Re: Class::__construct() vs. $this->__construct()
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-37024@lists.php.net to get a copy of this message
Justin Patrin wrote:
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.
As said earlier, this is incorrect. Both will do the same thing if Foo is the name of the class. $this stays set wherever you go once you're in a class method.
... unless you're using PHP5 in which case you get:
     "Fatal error:  Using $this when not in object context"
I'm assuming the use of $this->__construct() is to be compatible w/ PHP5 ... and so I'd imagine that you'd want your code not to completely break under PHP5 (!) -Hans

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