php标准库(SPL)概述

伊谢尔伦
发布: 2016-11-21 17:50:18
原创
2539人浏览过

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.

立即学习PHP免费学习笔记(深入)”;

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

PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号