http://www.51zxw.net/study.asp?vip=4857021
<?php
header("Content-Type:text/html;charset=UTF-8");
class Person{
public $userName='我是老爸';
public $age='58';
protected function play(){
echo '老爸,需要有人陪着打麻将!';
}
}
class Student extends Person{
public $userName='我是学生';
public $age='16';
public function play(){
parent::play();
echo '学生不能打麻将!';
}
}
$xiaoming = new Student();
$xiaoming->play(); //老爸,需要有人陪着打麻将!学生不能打麻将!
?>