php设计模式--门面模式
优势:松耦合,屏蔽组件。依赖分层
class ali { function buy(){ echo "买入阿里<br/>"; } function sell(){ echo "卖出阿里<br>"; } } class hds { function buy(){ echo "买入x德森<br/>"; } function sell(){ echo "卖出汉xx<br>"; } } class hfjy { function buy(){ echo "买入xxx<br/>"; } function sell(){ echo "卖出xx教育<br>"; } } class menmian { private $ali; private $hfjy; private $hds; function __construct(){ $this->ali = new ali(); $this->hds = new hds(); $this->hfjy = new hfjy(); } public function buy(){ $this->ali->buy(); } public function sell(){ $this->hfjy->sell(); $this->hds->sell(); } } $res = new menmian(); $res->buy(); echo "<hr>"; $res->sell();