<?php
/**
* 连续继承—— 人类
*/
class Person
{
public function walk()
{
echo "我是人类,我会走路<br />";
}
}
/**
* 爷爷继承人类
*/
class Ye extends Person
{
public function say()
{
echo "我是爷爷,我会说话 <br/>";
}
}
/**
* 父亲继承爷爷
*/
class Father extends Ye
{
}
/**
* 儿子继承父亲
*/
class Son extends Father
{
}
测试:
$son = new son();
$son->say();
$son->walk();
结果