PHP擴(kuò)展之PHP標(biāo)準(zhǔn)庫(SPL)概述
SPL是用于解決典型問題(standard problems)的一組接口與類的集合。
此擴(kuò)展只能在php 5.0以后使用,并且從PHP 5.3.0 不再被關(guān)閉,會(huì)一直有效,成為php內(nèi)核組件一部份。
數(shù)據(jù)結(jié)構(gòu)SPL提供了一組標(biāo)準(zhǔn)數(shù)據(jù)結(jié)構(gòu)。
雙向鏈表
雙向鏈表 (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 提供一系列標(biāo)準(zhǔn)異常。
LogicException?(extends?Exception)BadFunctionCallExceptionBadMethodCallExceptionDomainExceptionInvalidArgumentExceptionLengthExceptionOutOfRangeExceptionRuntimeException?(extends?Exception)OutOfBoundsExceptionOverflowExceptionRangeExceptionUnderflowExceptionUnexpectedValueExceptionSPL函數(shù)class_implements?— 返回指定的類實(shí)現(xiàn)的所有接口。class_parents?— 返回指定類的父類。class_uses?— Return the traits used by the given classiterator_apply?— 為迭代器中每個(gè)元素調(diào)用一個(gè)用戶自定義函數(shù)iterator_count?— 計(jì)算迭代器中元素的個(gè)數(shù)iterator_to_array?— 將迭代器中的元素拷貝到數(shù)組spl_autoload_call?— 嘗試調(diào)用所有已注冊的__autoload()函數(shù)來裝載請求類spl_autoload_extensions?— 注冊并返回spl_autoload函數(shù)使用的默認(rèn)文件擴(kuò)展名。spl_autoload_functions?— 返回所有已注冊的__autoload()函數(shù)。spl_autoload_register?— 注冊__autoload()函數(shù)spl_autoload_unregister?— 注銷已注冊的__autoload()函數(shù)spl_autoload?— __autoload()函數(shù)的默認(rèn)實(shí)現(xiàn)spl_classes?— 返回所有可用的SPL類spl_object_hash?— 返回指定對象的hash id文件處理SPL 提供 一些與文件相關(guān)的類。
SplFileInfoSplFileObjectSplTempFileObject其他類及接口ArrayObjectSplObserverSplSubject相關(guān)文章:
1. 利用CSS3新特性創(chuàng)建透明邊框三角2. phpstudy apache開啟ssi使用詳解3. phpstorm斷點(diǎn)調(diào)試方法圖文詳解4. ASP.NET Core實(shí)現(xiàn)中間件的幾種方式5. XML解析錯(cuò)誤:未組織好 的解決辦法6. ajax實(shí)現(xiàn)頁面的局部加載7. JavaScrip簡單數(shù)據(jù)類型隱式轉(zhuǎn)換的實(shí)現(xiàn)8. CSS可以做的幾個(gè)令你嘆為觀止的實(shí)例分享9. asp讀取xml文件和記數(shù)10. 在JSP中使用formatNumber控制要顯示的小數(shù)位數(shù)方法
