php设计模式 Interator (迭代器模式)
2011-11-11 09:00
621 查看
简介:这是php设计模式 Interator (迭代器模式)的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=339659' scrolling='no'>
爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具
http://biancheng.dnbcw.info/php/339659.html pageNo:7
class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=339659' scrolling='no'>
1 <?php 2 /** 3 * 迭代器模式 4 * 5 * 提供一个方法顺序访问一聚合对象中的各个元素,而又不暴露对象的内部表示 6 */ 7 interface Interator 8 { 9 public function next(); 10 public function first(); 11 public function current(); 12 public function isDone(); 13 } 14 15 class SomeInterator implements Interator 16 { 17 private $_arr = array(); 18 19 public function __construct($arr) 20 { 21 $this->_arr = $arr; 22 } 23 24 public function first() 25 { 26 return $this->_arr[0]; 27 } 28 29 public function current() 30 { 31 return current($this->_arr); 32 } 33 34 public function next() 35 { 36 return next($this->_arr); 37 } 38 39 public function isDone() 40 { 41 } 42 } 43 44 $objSomeInterator = new SomeInterator(array(1,2,3,4,6,7)); 45 echo $objSomeInterator->first(),"<br/>"; 46 echo $objSomeInterator->next(),"<br/>"; 47 echo $objSomeInterator->current(),"<br/>"; 48 echo $objSomeInterator->current(),"<br/>"; 49 echo $objSomeInterator->next(),"<br/>"; 50 echo $objSomeInterator->current(),"<br/>";
爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具
http://biancheng.dnbcw.info/php/339659.html pageNo:7
相关文章推荐
- [php]php设计模式 Interator (迭代器模式)
- php中的设计模式之--迭代器模式
- 初识PHP设计模式--迭代器模式
- php实现设计模式之 迭代器模式
- php设计模式(迭代器模式)
- php设计模式之迭代器模式
- PHP设计模式之迭代器模式(Iterator)
- PHP设计模式之迭代器模式
- PHP设计模式漫谈之迭代器模式
- 设计模式:迭代器模式-interator
- 慕课网----大话PHP设计模式 五(原型模式,装饰器模式,迭代器模式,代理模式)
- 19. 星际争霸之php设计模式--迭代器模式
- PHP设计模式之迭代器模式的深入解析
- PHP设计模式之迭代器模式
- 浅谈JAVA设计模式之——迭代器模式(interator)
- php设计模式之迭代器模式
- php设计模式 四 (观察者 原型模式 迭代器模式)
- PHP草根论之设计模式-迭代器模式
- PHP设计模式漫谈之迭代器模式
- PHP设计模式(6)迭代器模式