<?php /** * 外观模式 * 为其余子系统或者其余类. * 提供一个更高层的通用接口(或类). */ class TypeA { public function getMy () { echo 'TypeA'.PHP_EOL; } } class TypeB { public function getMy () { echo 'TypeB'.PHP_EOL; } } class TypeC { public function getMy () { echo 'TypeC'.PHP_EOL; } } /** * Class Exterior * 统一调用高级接口 */ class Exterior { protected $typeA; protected $typeB; protected $typeC; public function __construct() { $this->typeA = new TypeA(); $this->typeB = new TypeB(); $this->typeC = new TypeC(); } public function get () { $this->typeA->getMy(); $this->typeB->getMy(); $this->typeC->getMy(); } } $ext = new Exterior(); $ext->get(); //TypeA //TypeB //TypeC