使用关键字 extends
name=$name; $this->age=$age; $this->sex=$sex; } function say(){ echo '我的名字:',$this->name,'我的性别是',$this->sex,'我的年龄是',$this->age; echo ''; } function run(){ echo $this->name,'正在走路'; echo ''; } }class stu extends person{ var $school; function study(){ echo $this->name,'正在',$this->school,'学习'; echo ''; }}class teacher extends stu{ var $wage; function teaching(){ echo $this->name,'正在',$this->school,'教书','每月工资是',$this->wage; }}$teacher1= new teacher('张三','男',40);$teacher1->school='edu';$teacher1->wage=5000;$teacher1->say();$teacher1->run();$teacher1->teaching();/*打印结果是:我的名字:张三我的性别是男我的年龄是40张三正在走路张三正在edu教书每月工资是5000*/?>