PHP standard Library (SPL) Overview

Source: Internet
Author: User
Tags spl
SPL is a set of interfaces and classes that are used to solve typical problems (standard problems).

This extension can only be used after PHP 5.0 and is no longer closed from PHP 5.3.0, and will remain valid as part of the PHP kernel component.

Data

SPL provides a standard set of data structures.

Doubly linked list

A doubly 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 has 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

Heap

Heaps was tree-like structures that follow the Heap-property:each node was greater than or equal to their children when COM Pared using the implemented compare method which is global to the heap.

Splheap

Splmaxheap

Splminheap

Splpriorityqueue

Array

Arrays is structures that store the data in a continuous, accessible via indexes. Don ' t confuse them with PHP arrays:php arrays is in fact implemented as ordered Hashtables.

Splfixedarray

Mapping

A map is a datastructure holding key-value pairs. PHP arrays can seen as maps from integers/strings to values. SPL provides a map from objects to data. This map can also is used as an object set.

Splobjectstorage

Iterators

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 range of interfaces.

Countable

Outeriterator

Recursiveiterator

Seekableiterator

Splobserver

Splsubject

Abnormal

SPL provides a range of standard exceptions.

Logicexception (extends Exception)

Badmethodcallexception

Badfunctioncallexception

Domainexception

InvalidArgumentException

Lengthexception

Outofrangeexception

RuntimeException (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-calls a user-defined function for each element in the iterator

iterator_count-calculating the number of elements in an iterator

iterator_to_array-copying elements from an iterator to an array

Spl_autoload_call-attempts to call all registered __autoload () functions to load the request class

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

spl_autoload_functions-returns all registered __autoload () functions.

spl_autoload_register-Register __autoload () function

spl_autoload_unregister-Unregister a registered __autoload () function

Default implementation of the Spl_autoload-__autoload () function

spl_classes-return all available SPL classes

spl_object_hash-returns 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.