<?php class SiteInfo { var $url; function __construct($para) { $this->url = $para; } function setUrl($para){ $this->url = $para; } function getUrl(){ echo $this->url; } } $my = new SiteInfo("https://chanpinxue.cn"); $my->getUrl(); ?> <?php class SiteInfoBoy extends SiteInfo { var $url; function __construct($para) { $this->url = $para; } function setUrl($para){ $this->url = $para; } function getUrl(){ // 调用父类中被覆盖的方法 parent::getUrl(); echo ' website:'. $this->url; } } $me = new SiteInfoBoy("http://chanpinxue.cn"); $me->getUrl(); ?>