Re: Bug #2675: Misbehavior of object initializers

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: Bug #2675: Misbehavior of object initializers
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-12157@lists.php.net to get a copy of this message
On Sat, 6 Nov 1999 zerodiv@zerodivide.net wrote: > From: zerodiv@zerodivide.net > Operating system: all tested > PHP version: 3.0.12 > PHP Bug Type: Other > Bug description: Misbehavior of object initializers > > <?php > class Foo { > var $type; > Function Foo() { > $this->type = 'Foo'; > } > } > > class Bar { > var $type; > Function Bar() { > $this->type = 'Bar'; > } > } > > // This will work > $foo = new Foo(); > echo( 'I am foo : ' . $this->type ); > > // This will not > $bar = new Bar(); > echo( 'I should be foo also : ' . $this->type ); > > ?> I really don't understand this example. You can't use $this outside of the clas that way. How in the world is PHP supposed to know which object you are referring to? Those echoes must surely need to be $foo->type and $bar->type, or am I missing some subtle point you are trying to show? -Rasmus

« previous php.dev (#12157) next »