Php Standard Library (SPL) Overview

Source: Internet
Author: User
Tags spl
PHP extension-Overview of the PHP standard Library (SPL) SPL is a set of interfaces and classes used to solve typical problems (standard problems.

This extension can only be used later than php 5.0 and will remain valid since PHP 5.3.0 is disabled. it will become part of the php kernel component.

Data structure

SPL provides a set of standard data structures.

Two-Way linked list

Two-Way 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.

Spldoublyasklist

SplStack

SplQueue

Heap

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

Array

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

Ing

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

Iterator

SPL provides a series of iterators to traverse different objects.

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

Interface

SPL provides a series of interfaces.

Countable

OuterIterator

RecursiveIterator

SeekableIterator

SplObserver

SplSubject

Exception

SPL provides a series of standard exceptions.

LogicException (extends Exception)

BadMethodCallException

BadFunctionCallException

DomainException

InvalidArgumentException

LengthException

OutOfRangeException

RuntimeException (extends Exception)

OutOfBoundsException

OverflowException

RangeException

UnderflowException

UnexpectedValueException

SPL functions

Class_implements-return all interfaces implemented by the specified class.

Class_parents-return the parent class of the specified class.

Class_uses-Return the traits used by the given class

Iterator_apply-calls a user-defined function for each element in the iterator

Iterator_count-calculate the number of elements in the iterator

Iterator_to_array-copy the elements in the iterator to the array

Spl_autoload_call-call all registered _ autoload () functions to load the request class

Spl_autoload_extensions-registers and returns the default file extension used by the spl_autoload function.

Spl_autoload_functions-returns all registered _ autoload () functions.

Spl_autoload_register-register _ autoload () function

Spl_autoload_unregister-deregister the registered _ autoload () function

Default implementation of the spl_autoload-_ autoload () function

Spl_classes-returns all available SPL classes

Spl_object_hash-return the hash id of the specified object

File processing

SPL provides some file-related classes.

SplFileInfo

SplFileObject

SplTempFileObject

Other classes and interfaces

ArrayObject

SplObserver

SplSubject

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.