class Duck {
public function quack() {
$this->swim();
}
public function swim() {
echo 'I\'m swimming!';
}
}
class Plane {
public function fly() {
Duck::quack();
}
public function swim()
{
echo 'I can\'t swim! People are DROWNING!';
}
}
$plane = new Plane();
$plane->fly();
我被问到上述问题并给出了输出是非法调用静态方法的错误的答案。
但它实际上打印“我在游泳!”。
有人可以解释为什么会这样吗?