php spl 修改某个值,PHP SPL笔记

这几天,我在学习PHP语言中的SPL

这个东西应该属于PHP中的高级内容,看上去很复杂,但是非常有用,所以我做了长篇笔记。不然记不住,以后要用的时候,还是要从头学起。

由于这是供自己参考的笔记,不是教程,所以写得比较简单,没有多解释。但是我想,如果你是一个熟练的PHP5程序员,应该足以看懂下面的材料,而且会发现它很有用。现在除此之外,网上根本没有任何深入的SPL中文介绍。

================

PHP SPL笔记

目录

第一部分 简介

1. 什么是SPL?

2. 什么是Iterator?

第二部分 SPL Interfaces

3. Iterator界面

4. ArrayAccess界面

5. IteratorAggregate界面

6. RecursiveIterator界面

7. SeekableIterator界面

8. Countable界面

第三部分 SPL Classes

9. SPL的内置类

10. DirectoryIterator类

11. ArrayObject类

12. ArrayIterator类

13. RecursiveArrayIterator类和RecursiveIteratorIterator类

14. FilterIterator类

15. SimpleXMLIterator类

16. CachingIterator类

17. LimitIterator类

18. SplFileObject类

第一部 简介

1. 什么是SPL?

SPL是Standard PHP Library(PHP标准库)的缩写。

根据官方定义,它是“a collection of interfaces and classes that are meant to solve

standard

problems”。但是,目前在使用中,SPL更多地被看作是一种使object(物体)模仿array(数组)行为的interfaces和classes。

2. 什么是Iterator?

SPL的核心概念就是Iterator。这指的是一种Design Pattern,根据《Design

Patterns》一书的定义,Iterator的作用是“provide an object which traverses some aggregate

structure, abstracting away assumptions about the implementation of that

structure.”

wikipedia中说,"an iterator is an object which allows a programmer to traverse

through all the elements of a collection, regardless of its specific

implementation".……"the iterator pattern is a design pattern in which iterators

are used to access the elements of an aggregate object sequentially without

exposing its underlying representation".

通俗地说,Iterator能够使许多不同的数据结构,都能有统一的操作界面,比如一个数据库的结果集、同一个目录中的文件集、或者一个文本中每一行构成的集合。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值