我正在尝试用 PHP 编写以下代码
class A {
 protected static $comment = "I am A" ;
 public static function getComment () {
  return self :: $comment; 
 }
}
class B extends A {
 protected static $comment = "I am B" ;
}
echo B::getComment () ; // echoes "I am A"
它不应该返回I am B吗?在oop PHP中,孩子不会覆盖父母吗?谢谢你的澄清。
== 编辑 ==
另外我的问题是静态和实例之间有什么区别,因为在实例中它可以工作:
class A {
    protected $comment = "I am A" ;
    public function getComment () {
        return $this -> comment ;
    }
}
class B extends A {
    protected $comment = "I am B" ;
}
$B=new B ;
echo $B->getComment();