<html>
<body>
class MyClass {
protected $number = 0;
}
class AnotherClass extends MyClass {
public function add1() {
$this->number++;
}
public function getNumber() {
return $this->number;
}
}
$obj = new AnotherClass();
$obj->add1();
echo "数字是 " . $obj->getNumber();
</body>
</html>