调用重写的父方法

kil*_*129 26 php overriding object

在以下示例代码,该方法test()在父类Foo是由该方法覆盖test()在子类Bar.是否有可能调用Foo::test()Bar::test()

class Foo 
{
  $text = "world\n";

  protected function test() {
    echo $this->text;
  }
}// class Foo

class Bar extends Foo 
{
  public function test() {
    echo "Hello, ";

    // Cannot use 'parent::test()' because, in this case,
    // Foo::test() requires object data from $this
    parent::test();
  }
}// class Bar extends Foo

$x = new Bar;
$x->test();
Run Code Online (Sandbox Code Playgroud)