php标准库(SPL)概述
此扩展只能在php 5.0以后使用,并且从PHP 5.3.0 不再被关闭,会一直有效,成为php内核组件一部份。
数据结构
SPL提供了一组标准数据结构。
双向链表
双向链表 (DLL) is a list of nodes linked in both directions to each others. Iterator's operations, access to both ends, addition or removal of nodes have a cost of O(1) when the underlying structure is a DLL. It hence provides a decent implementation for stacks and queues.
SplDoublyLinkedList
SplStack
SplQueue
堆
Heaps are tree-like structures that follow the heap-property: each node is greater than or equal to its children, when compared using the implemented compare method which is global to the heap.
SplHeap
SplMaxHeap
SplMinHeap
SplPriorityQueue
阵列
Arrays are structures that store the data in a continuous way, accessible via indexes. Don't confuse them with PHP arrays: PHP arrays are in fact implemented as ordered hashtables.
SplFixedArray
映射
A map is a datastructure holding key-value pairs. PHP arrays can be seen as maps from integers/strings to values. SPL provides a map from objects to data. This map can also be used as an object set.
SplObjectStorage
迭代器
SPL 提供一系列迭代器以遍历不同的对象。
ArrayIterator
RecursiveArrayIterator
EmptyIterator
IteratorIterator
CallbackFilterIterator
RecursiveFilterIterator
RegexIterator
RecursiveCallbackFilterIterator
ParentIterator
RecursiveRegexIterator
RecursiveCachingIterator
AppendIterator
CachingIterator
FilterIterator
InfiniteIterator
LimitIterator
NoRewindIterator
MultipleIterator
RecursiveIteratorIterator
RecursiveTreeIterator
DirectoryIterator (extends SplFileInfo)
GlobIterator
RecursiveDirectoryIterator
FilesystemIterator
接口
SPL 提供一系列接口。
Countable
OuterIterator
RecursiveIterator
SeekableIterator
SplObserver
SplSubject
异常
SPL 提供一系列标准异常。
LogicException (extends Exception)
BadMethodCallException
BadFunctionCallException
DomainException
InvalidArgumentException
LengthException
OutOfRangeException
RuntimeException (extends Exception)
OutOfBoundsException
OverflowException
RangeException
UnderflowException
UnexpectedValueException
SPL函数
class_implements — 返回指定的类实现的所有接口。
class_parents — 返回指定类的父类。
class_uses — Return the traits used by the given class
iterator_apply — 为迭代器中每个元素调用一个用户自定义函数
iterator_count — 计算迭代器中元素的个数
iterator_to_array — 将迭代器中的元素拷贝到数组
spl_autoload_call — 尝试调用所有已注册的__autoload()函数来装载请求类
spl_autoload_extensions — 注册并返回spl_autoload函数使用的默认文件扩展名。
spl_autoload_functions — 返回所有已注册的__autoload()函数。
spl_autoload_register — 注册__autoload()函数
spl_autoload_unregister — 注销已注册的__autoload()函数
spl_autoload — __autoload()函数的默认实现
spl_classes — 返回所有可用的SPL类
spl_object_hash — 返回指定对象的hash id
文件处理
SPL 提供 一些与文件相关的类。
SplFileInfo
SplFileObject
SplTempFileObject
其他类及接口
ArrayObject
SplObserver
SplSubject