<?php
class a
{
protected $c=10;
}
class b extends a{
echo a::$c;
}
//$obj = new b();
?>
这里我试图在子类中打印父类变量。你能告诉我如何在PHP5中使用子类中的父类变量吗?
答案 0 :(得分:1)
class parent {
protected $field;
}
class child extends parent {
public function test() {
return $this->field;
}
}