随笔分类 -  PHP面向对象思想(设计模式)

摘要:PHP命名空间 可以更好地组织代码,与Java中的包类似。 Test1.php <?php namespace Test1;//命名空间Test1 function test(){ echo __FILE__; } Test2.php <?php namespace Test2; //命名空间Tes 阅读全文
posted @ 2020-02-16 10:12 骏码信息 阅读(292) 评论(0) 推荐(0)
摘要:"条记录", 'prev' => "上一页", 'next' => "下一页", 'first'=> "首页", 'last' => "末页" ); //在分页信息中显示内容,可以自己通过set... 阅读全文
posted @ 2017-12-24 19:15 骏码信息 阅读(319) 评论(0) 推荐(0)
摘要:width=$width; $this->height=$height; $this->num=$num; $this->fontsize=$fontsize; $this->pixes=$pixes; $this->lines=$lines; ... 阅读全文
posted @ 2017-12-23 21:07 骏码信息 阅读(301) 评论(0) 推荐(0)
摘要:createDB(); $db->conn(); 阅读全文
posted @ 2016-08-24 11:17 骏码信息 阅读(160) 评论(0) 推荐(0)
摘要:send=$send; } abstract public function msg($content); public function send($to,$content){ $content=$this->msg($content); $this->send->send($to,$content); ... 阅读全文
posted @ 2016-08-23 17:14 骏码信息 阅读(282) 评论(0) 推荐(0)
摘要:28 ,'wind'=> 7,'sun'=>'sunny'); return serialize($today); } } //增加一个适配器,转换为json格式的数据 class AdapterTianqi extends tianqi{ public static function show(){ ... 阅读全文
posted @ 2016-08-23 14:18 骏码信息 阅读(240) 评论(0) 推荐(0)
摘要:content=$content; } public function decorator(){ return $this->content; } } //摘要 class BianArt extends BaseArt{ public function __construct(BaseArt $art){ $this->art=$ar... 阅读全文
posted @ 2016-08-23 10:02 骏码信息 阅读(272) 评论(0) 推荐(0)
摘要:策略模式实现简单的计算器功能 阅读全文
posted @ 2016-08-19 17:33 骏码信息 阅读(184) 评论(0) 推荐(0)
摘要:power){ echo "版主删帖"; }else{ $top=new $this->top; $top->process($lev); } } } class admin{ ... 阅读全文
posted @ 2016-08-19 16:08 骏码信息 阅读(364) 评论(0) 推荐(0)
摘要:观察者模式属于行为模式,是定义对象间的一种一对多的依赖关系,以便当一个对象的状态发生改变时,所有依 赖于它的对象都得到通知并自动刷新。它完美的将观察者对象和被观察者对象分离。可以在独立的对象(主体)中维护一个对主体感兴趣的依赖项(观察器)列表。 让所有观察器各自实现公共的 Observer 接口,以 阅读全文
posted @ 2016-08-19 11:35 骏码信息 阅读(743) 评论(0) 推荐(0)
摘要:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>面向对象之观察者模式</title> </head> <style type="text/css"> .word{ width:500px; height: 1 阅读全文
posted @ 2016-08-18 16:29 骏码信息 阅读(227) 评论(0) 推荐(0)
摘要:1 _db; 19 } 20 } 21 ////使用单例模式后不能直接new对象,必须调用getInstance获取 22 $conn1=Dbconn::getInstance(); 23 $_db=$conn1->connect(); 24 //第二次调用是同一个实例,_counter还是1 25 $conn2=Dbconn::getInstance(); 26 $_... 阅读全文
posted @ 2015-10-25 21:30 骏码信息 阅读(292) 评论(0) 推荐(0)