我似乎无法覆盖protected static
变量。这很烦人,因为你也不能覆盖任何私有变量。我该怎么解决?(必须支持PHP 5.2)
<?
class Foo{
protected static $stuff = 'Foo';
public function showStuff(){
echo self::$stuff . PHP_EOL;
}
}
class Bar extends Foo{
protected static $stuff = 'Bar';
}
$f = new Foo();
$b = new Bar();
$f->showStuff(); // Output: Foo
$b->showStuff(); // Output: Foo
?>