static call to an instance method in a class definition
| From: | samuel | Date: | Thu, 22 Jul 2010 16:09:36 +0000 |
| Subject: | static call to an instance method in a class definition | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-30252@lists.php.net to get a copy of this message | ||
Hello,
Making a mistake I just come to discover ( for myself ) a strange fiture in
php,
lets see an example :
class A{
public $foo = 'bar';
public function write(){
print($this->foo);
}
}
class B{
public $foo = 'gnagnagna';
public function write(){
A::write();
}
}
$var = new B;
$var->write();
This code will not throw excaption and output gnagnagna, it's kind of cross
définition something,
I know something like that exists in other language but I didn't expect PHP
to work like that.
Do you know this ? And why ?