【发布时间】:2012-07-17 18:27:20
【问题描述】:
我有以下结构
class Foo
{
public static $a = "parent";
public static function Load()
{
return static::$a;
}
public function Update()
{
return self::$a;
}
}
class Bar extends Foo
{
private static $a = "child";
}
我希望 Update 函数也能够返回 $a,但我无法让它工作。
Bar::Load(); //returns child, Correct.
$bar = new Bar();
$bar->Update(); //returns parent, Wrong.
我试过 self:: 、 static:: 和 get_class() 都没有成功。
【问题讨论】:
标签: php oop inheritance static non-static