标签:抽象工厂模式
<?php /** * 抽象工厂模式 */ header("Content-type: text/html; charset=utf-8"); class blogAppPannel { function getPannel() { return ‘这是博客频道页<br>‘; } } abstract class commsManager { const PANNEL = 1; const LISTS = 2; const VIEW = 3; abstract function getHeadText(); abstract function make($flag); abstract function getFootText(); } class BlogCommsManage extends commsManager { function getHeadText() { return ‘这是博客头部<br>‘; } function make($flag) { switch ($flag) { case self::PANNEL: return new blogAppPannel(); case self::LISTS: return new blogAppList; case self::VIEW: return new blogAppView; } } function getFootText() { return ‘这是博客尾部<br>‘; } } $blog = new BlogCommsManage; echo $blog->getHeadText(); $p=$blog->make(‘1‘); echo $p->getPannel(); echo $blog->getFootText(); echo ‘<br>‘; ?>
ASDFGHJJ
标签:抽象工厂模式
原文地址:http://5345125.blog.51cto.com/5335125/1541255