![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
设计模式
freedomai
这个作者很懒,什么都没留下…
展开
-
工厂模式
interface DB { function conn():}interface Factory { function createDB();}class mysqlFactory implements Factory { public function createDB() { return new dbmysql原创 2014-09-23 20:52:46 · 334 阅读 · 0 评论 -
适配器模式
//适配器模式//服务端代码class tianqi { public static function show() { $today = array('tep'=>28, 'wind'=>7, 'sun'=>'sunny'); return serialize($today); }}//增加一个适配器class原创 2014-10-04 22:26:59 · 292 阅读 · 0 评论 -
桥接模式
abstract class info { protected $send = null; public function __construct($send) { $this->send = $send; } abstract public function msg($content); pu原创 2014-10-04 23:49:22 · 324 阅读 · 0 评论 -
装饰器模式
//场景:BaseArt//装饰器模式做文章修饰功能class BaseArt { protected $content; protected $art = null; public function __construct($content) { $this->content = $content; }原创 2014-10-04 22:00:31 · 267 阅读 · 0 评论 -
责任链模式
class board { //版主权限等级 protected $power = 1; //上级 protected $top = 'admin'; public function process($lev) { if($lev power) { echo '版主删帖';原创 2014-10-04 19:08:01 · 328 阅读 · 0 评论 -
策略模式
场景:根据传递的参数不同,进行加减乘除运算$ope = $_POST['ope原创 2014-10-04 19:33:11 · 268 阅读 · 0 评论 -
单例模式
class sigle { protected static $ins = null; public static function getIns() { if( self :: $ins ===原创 2014-10-03 21:28:54 · 313 阅读 · 0 评论 -
设计模式简单介绍
设计模式作用:1.让代码原创 2014-09-23 19:31:32 · 364 阅读 · 0 评论 -
观测者模式
PHP5.1以上自带了观察者模式的接口:原创 2014-10-04 17:58:40 · 381 阅读 · 0 评论 -
简单工厂模式
工厂模式:作用:减少new的操作原创 2014-09-23 20:27:27 · 374 阅读 · 0 评论