static call to an instance method in a class definition

samuel <[email protected]>
Newsgroups gmane.comp.php.windows
Message-ID <[email protected]>
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 ?
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.