php extends
<?php
header("content-type:text/html;charset=utf-8");
class Person extends Animal{
public $PersonSex;//性别
public $PersonAge;//年龄
//继承者的构造函数
function __construct($personSex,$PersonAge){
$this->PersonSex = $personSex;
$this->personAge = $personAge;
}
function printPerson(){
print ($this->name." is ".$this->PersonSex.",$this year".$this->PersonAge);
}
}
//实例化person对象
$personobject = new perosn("male","21");
//打印执行
$personObject->printPerson();
class Animal{
//基类的属性
public $name;//名字
public function __construct($name){
$this->name = name;
}
}