:: abused for static method call

From: Date: Sun, 25 Jun 2000 19:47:30 +0000
Subject: :: abused for static method call
Groups: php.general 
Request: Send a blank email to php-general+get-3020@lists.php.net to get a copy of this message
Hi! I'm surprised that the following code works and prints 8: <?php class foo { var $bar = 0; function foo() { $this->bar = 8; prints $this->bar; } } foo::foo() ?> Why can I use "::" outside a class? Looks like a side effect or is this intented. I don't not belive that it is, right? If it's so why can the foo constructor access a property using the pseudo object $this it can't access another method using $this? This will cause an error: <?php class foo { function foo() { $this->bar(); } function bar() { } } foo::foo(); ?> Ulf

« previous php.general (#3020) next »