静态调用父级的私有实例方法

时间:2018-03-06 19:41:51

标签: php

我已尝试使用Late Static Bindings并尝试使用self ::和static ::然后得到一些非常奇怪的东西。我不明白脚本如何在没有任何警告的情况下执行(error_reporting = E_ALL)。任何人都可以尝试解释它是如何工作的吗?

class A {
  private function privateWho() {
    echo __CLASS__.PHP_EOL;
  }
  public function test() {
    B::privateWho();
  }
}

class B extends A {}

$b = new B();
$b->test(); // prints A

0 个答案:

没有答案
相关问题