php面向对象继承的初步使用
2021-06-23 07:06
标签:int extend class tor struct nbsp 对象 ons bsp /** class Person{ public $name; public function __construct($name, $age) public function desc(){ } class Man extends Person{ public function desc(){ } public function desc(){ $person = new Man(‘李四‘, 25); $person = new Woman(‘丽丽‘, 28); php面向对象继承的初步使用 标签:int extend class tor struct nbsp 对象 ons bsp 原文地址:http://www.cnblogs.com/zxy945/p/7162053.html
* Created by PhpStorm.
* User: fu
* Date: 2017/7/13
* Time: 13:34
*/
public $age;
{
$this->name = $name;
$this->age = $age;
}
public function introduce(){
echo ‘姓名:‘.$this->name.‘,年龄:‘.$this->age;
$this->desc();
}
}
echo ‘,男性有胡子
‘;
}
class Woman extends Person{
echo ‘,女生喜欢购物
‘;
}
}
$person->introduce();
$person->introduce();