url = $par1; $this->title = $par2; } function getUrl() { echo $this->url . PHP_EOL; } function getTitle() { echo $this->title . PHP_EOL; } } // 子类扩展站点类别 class Twle extends Site { var $category; function setCate($par) { $this->category = $par; } function getCate() { echo $this->category . PHP_EOL; } function getUrl() { return $this->url . PHP_EOL; } function getTitle() { return $this->title . PHP_EOL; } } $twle = new Twle('www.twle.cn','简单教程'); $twle->setCate('在线教育'); echo $twle->getTitle(); echo $twle->getUrl(); $twle->getCate(); echo '
PHP 基础教程 - 简单教程(www.twle.cn)
';