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

From: Date: Wed, 30 Mar 2005 22:27:17 +0000
Subject: Re: Class::__construct() vs. $this->__construct()
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-37003@lists.php.net to get a copy of this message
On Wednesday 30 March 2005 02:18 pm, Justin Patrin wrote: > On Wed, 30 Mar 2005 14:07:39 -0800, Ian Eure <ieure@php.net> wrote: > > On Wednesday 30 March 2005 01:50 pm, Joe Stump wrote: > > > Thoughts? > > > > From a PHP4 constructor, it needs to be $this->__construct(), otherwise > > __construct() runs outside the context of the newly instantiated object > > (i.e. there's no $this to initialize). > > > > I'm not sure about the parent::__construct() use. Does anyone know if > > this a special case which allows use of $this, unlike other static calls? > > In C++ this would be the case, but if you run a function with :: $this > is still available. Check out this code (which is even more > disturbing): > I know that $this is still available when making a static call on an instantiated class in PHP 4, but my understanding is: - It's Bad(tm), in the same way returning from a constructor is Bad(tm). - It's ambiguous; if you have 3 instances, which one does $this point at? - It doesn't work in PHP 5 (or won't work in a future version)

Attachment: [application/pgp-signature]
« previous php.pear.dev (#37003) next »