PHP扩展之PHP标准库(SPL)概述
SPL是用于解决典型问题(standard problems)的一组接口与类的集合。
此扩展只能在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.
SplDoublyLinkedListSplStackSplQueue堆
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.
SplHeapSplMaxHeapSplMinHeapSplPriorityQueue阵列
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 提供一系列迭代器以遍历不同的对象。
ArrayIteratorRecursiveArrayIteratorEmptyIteratorIteratorIteratorAppendIteratorCachingIteratorRecursiveCachingIteratorFilterIteratorCallbackFilterIteratorRecursiveCallbackFilterIteratorRecursiveFilterIteratorParentIteratorRegexIteratorRecursiveRegexIteratorInfiniteIteratorLimitIteratorNoRewindIteratorMultipleIteratorRecursiveIteratorIteratorRecursiveTreeIteratorDirectoryIterator (extends SplFileInfo)FilesystemIteratorGlobIteratorRecursiveDirectoryIterator接口SPL 提供一系列接口。
CountableOuterIteratorRecursiveIteratorSeekableIteratorSplObserverSplSubject异常SPL 提供一系列标准异常。
LogicException (extends Exception)BadFunctionCallExceptionBadMethodCallExceptionDomainExceptionInvalidArgumentExceptionLengthExceptionOutOfRangeExceptionRuntimeException (extends Exception)OutOfBoundsExceptionOverflowExceptionRangeExceptionUnderflowExceptionUnexpectedValueExceptionSPL函数class_implements — 返回指定的类实现的所有接口。class_parents — 返回指定类的父类。class_uses — Return the traits used by the given classiterator_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 提供 一些与文件相关的类。
SplFileInfoSplFileObjectSplTempFileObject其他类及接口ArrayObjectSplObserverSplSubject相关文章: