标签:
<?php //文章父类 class BaseArt{ protected $content; protected $art; public function __construct($content){ $this->content=$content; } public function decorator(){ return $this->content; } } //摘要 class BianArt extends BaseArt{ public function __construct(BaseArt $art){ $this->art=$art; $this->decorator(); } public function decorator(){ return $this->content=$this->art->decorator().‘文章摘要‘; } } //SEO关键词 class SEOArt extends BaseArt{ public function __construct(BaseArt $art){ $this->art=$art; $this->decorator(); } public function decorator(){ return $this->content=$this->art->decorator().‘SEO优化‘; } } $BA=new BaseArt(‘天天向上‘); $b=new BianArt($BA); echo $b->decorator(); $c=new SEOArt($b); echo $c->decorator();
标签:
原文地址:http://www.cnblogs.com/kangshuai/p/5798142.html