php面向对象--继承
<?phpclass Person {
protected $name;
public function __construct($name) {
$this->name = $name;
}
public function showPersonInfo() {
echo "person name: " . $this->name;
}
}
class Developer extends Person{
protected $macType;
public function __construct($name,$macType) {
parent::__construct($name);
$this->macType = $macType;
}
public function showPersonInfo() {
echo "developer name:" . $this->name . " developer's mac type:" . $this->macType;
}
}
$developer = new Developer("goodboy","MBP");
$developer->showPersonInfo();
?>
页:
[1]