这可能是一个重复的帖子,但搜索答案只是让我采用C,Java和ColdFusion的方式来做这个......
给定A类方法foo()
,B类扩展A并且foo()
,我想运行类似的东西:
$b = new B();
$b->A::foo(); (this is working C syntax, but that doesn't seem to work)
答案 0 :(得分:2)
您不能直接从对象中调用它,您必须在A->foo()
内调用它,例如:
class A
{
function foo()
{
echo "I am A::foo() and provide basic functionality.<br />\n";
}
}
class B extends A
{
function foo()
{
parent::foo();
}
}
$b = new B;
$b->foo();