Home > Backend Development > PHP Tutorial > PHP Standard Library (SPL) Overview

PHP Standard Library (SPL) Overview

伊谢尔伦
Release: 2016-11-21 17:50:18
Original
2329 people have browsed it

SPL is a collection of interfaces and classes used to solve standard problems.

This extension can only be used after PHP 5.0, and will no longer be closed from PHP 5.3.0. It will always be effective and become a part of the PHP kernel component.

Data Structures

SPL provides a set of standard data structures.

Double Linked List

Double Linked List (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 Don 't confuse them with PHP arrays: PHP arrays are in fact implemented as ordered hashtables.

SplFixedArray

map

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.

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

Interfaces

SPL provides a series of interfaces.

Countable

OuterIterator

RecursiveIterator

SeekableIterator

SplObserver

SplSubject

Exceptions

SPL provides a series of standard exceptions.

LogicException (extends Exception)

BadMethodCallException

BadFunctionCallException

DomainException

InvalidArgumentException

LengthException

OutOfRangeException

Runtime Exception (extends Exception)

OutOfBoundsException

OverflowException

RangeException

UnderflowException

UnexpectedValueException

SPL Function

class_implements — Returns all interfaces implemented by the specified class.

class_parents — Returns the parent class of the specified class.

class_uses — Return the traits used by the given class

iterator_apply — Call a user-defined function for each element in the iterator

iterator_count — Count the number of elements in the iterator

iterator_to_array — Change the items in the iterator Elements are copied to the array

spl_autoload_call — Try to call all registered __autoload() functions to load the requested class

spl_autoload_extensions — Register and return the default file extension used by the spl_autoload function.

spl_autoload_functions — Returns all registered __autoload() functions.

spl_autoload_register — Register the __autoload() function

spl_autoload_unregister — Unregister the registered __autoload() function

spl_autoload — The default implementation of the __autoload() function

spl_classes — Return all available SPL classes

spl_ object_hash — returns the specified Object hash id

File processing

SPL provides some file-related classes.

SplFileInfo

SplFileObject

SplTempFileObject

Other classes and interfaces

ArrayObject

SplObserver

SplSubject

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template