随笔分类 - 面向对象,设计模式
摘要:感觉序列化和反序列化用得倒是比较少了,而json_encode和json_decode用得相对多,都是转化成串,进行入库、传输等。json更方便,但是序列化和反序列化结合这两个魔术方法使用倒还行a = 'hello';//反序列化时进行a值的修改动作	}}$m = new Test();$n = s...
        阅读全文
                
摘要:代码片段一:contact[] = $tel;	} public function delTel($tel){ $key = array_search($tel, $this->contact); if($key !== FALSE){ unset($this->contact[$key]...
        阅读全文
                
摘要:name.' '; echo $this->price.'元';	}}//生成对象。$coffee = new coffee();//$coffee->showprice();//上面我已经生成了一个对象,现在已经在线上运行//但是我想动态的为coffee对象添加功能,而不改变原有的类和继承关...
        阅读全文
                
摘要:flat();//以上是已经存在的对象小明,他在中国用扁形孔来充电//现在他到了欧洲,欧洲充电是圆形孔//目标接口interface Europe{	public function round();}//适配器,包含源接口,实现(继承)目标接口class European implements Eu...
        阅读全文
                
摘要:name = $name;	} public function setType($type){ $this->type = $type;	} public function setPrice($price){ $this->price = $price;	}	public function ...
        阅读全文
                
摘要:getName(),' visitd by ConcerteVisitor1 '; } public function visitConcreteElementB(ConcreteElementB $elementB){ echo $elementB->ge...
        阅读全文
                
摘要:interpreter($temp); }	}}$obj = new Interpreter();$obj->execute("sdf12345abc");?> UML 类图如下:
        阅读全文
                
摘要:author = $author; $this->title = $title;	} public function getTitle(){ return $this->title;	} public function getAuthor(){ return $this->author;	...
        阅读全文
                
摘要:mediator = $mediator;	} public function send($message){ $this->mediator->send($message,$this);	} abstract function notify($message);}//具体的同事类a b c ...
        阅读全文
                
摘要:next_handler = $handler;	} abstract public function executeRequest($request);} //具体的处理者,如果能处理,自己处理,不能处理,留给下一个继任者class Leader extends Handler{	public ...
        阅读全文
                
摘要:name = $name; } public function action(){ echo $this->name.'跳大';	} public function action1(){ echo $this->name.'防御';	} public function action2(...
        阅读全文
                
摘要:car = $car; $this->speed = $speed;	} public function run(){ echo $this->car->run(); echo $this->speed->showSpeed(); echo '行驶在普通街道上';	}}class Free...
        阅读全文
                
摘要:aggregate = $aggregate; $this->aggregateCount = $this->aggregate->getCounts();	} public function first(){ $this->index = 0;	} public function ne...
        阅读全文
                
摘要:name = $name;	} public function display(){//树叶只展示自身名字即可 echo $this->name;	}}//树枝构件class file extends dir{	public $name;	public $items=array();	publi...
        阅读全文
                
摘要:state = $state;	} public function show(){ echo $this->state."";	} public function setmemento(){//保存至备忘录 return new memento($this->state);	} publi...
        阅读全文
                
摘要:set(new offstate());	}}class offstate implements state{	public function show(){ echo '是关灯状态';	} public function handle($light){ $light->set(new ons...
        阅读全文
                
摘要:createmitwo();$n->colorvoice();?>
        阅读全文
                
摘要:";	}	public function Method2()	{ echo "abstract Method2";	}	public function Method3()	{ echo "abstract Method3";	}	public function doSomeThing()//骨架...
        阅读全文
                
摘要:state = $state;	} public function getState(){ return $this->state;	} public function copy(){ return clone $this;//浅拷贝 /* * 深拷贝 */// $tmp = s...
        阅读全文
                
摘要:createobj();$m->work();?> UML类图如下
        阅读全文
                
 
                    
                
 浙公网安备 33010602011771号
浙公网安备 33010602011771号