摘要: _observers = array();}/*** 增加一个新的观察者对象* @param Observer $observer*/public function attach(Observer $observer) {return array_push($this->_observers, $o... 阅读全文
posted @ 2013-06-14 15:54 feiyuhit 阅读(143) 评论(0) 推荐(0) 编辑
摘要: <?php/** * 抽象策略角色,以接口实现 * interface只包含方法、委托或事件的签名; */interface FlyInterface { public function fly();} /** * 具体策略A:用翅膀飞行 */class FlyWithWing implements FlyInterface { public function fly() { echo "我用翅膀飞行\n"; }} /** * 具体策略角色B:用脚飞行 */class FlyWithFoot implements FlyInterface { pu... 阅读全文
posted @ 2013-06-14 13:36 feiyuhit 阅读(147) 评论(0) 推荐(0) 编辑
摘要: abstract修饰符可以和类、方法、属性、索引器及事件一起使用。在类声明中使用 abstract 修饰符以指示某个类只能是其他类的基类。标记为抽象或包含在抽象类中的成员必须通过从抽象类派生的类来实现。抽象类不能被实例化。<?php/** 飞行接口*/abstract class InterfaceFly{ abstract function fly(); public function getInstance($interfaceFly){ return new $interfaceFly; }}/** 飞行接口实现方法*/class FlyWithWind ... 阅读全文
posted @ 2013-06-14 11:58 feiyuhit 阅读(187) 评论(0) 推荐(0) 编辑