我有以下课程:
<?php
Abstract Class A{
public function foo(){
self::bar();
}
Abstract public static function bar($arg);
}
Class B extends A{
public static function bar(){
echo "Class B";
}
}
Class C extends A{
public static function bar(){
echo "Class C";
}
}
?>
我需要从 foo() 调用实例化类的方法 bar():
<?php
$obj1 = new B();
$obj2 = new C();
$obj1->foo(); // I expect to get 'Class B'
$obj2->foo(); // I expect to get 'Class C'
?>
提前致谢。