SPL標準庫的使用php
SPL是用於解決典型問題(standard problems)的一組接口與類的集合。數組
一、SPL提供了不少數據結構類,如SplStack、SqlQueue、SqlHeap、SplFixedArray等數據結構
實例代碼以下:函數
a、棧3d
b、隊列對象
c、定長數組blog
二、PHP鏈式操做的實現接口
index.php隊列
IMooc/Database.php字符串
三、PHP魔術方法
a、__get\__set:對象屬性的管理
index.php
Object.php
output : string(19) "IMooc\Object::__get" hello
b、__call\callStatic:控制對象方法的調用
index.php
Object.php
output:
string(4) "test" array(2) { [0]=> string(5) "hello" [1]=> int(123) }
string(8) "sayHello" array(2) { [0]=> string(8) "helloJiu" [1]=> string(8) "helloPHP" }
c、__toString():將一個PHP對象轉化成字符串
d、__invoke():將一個對象當成函數調用時,會調用這個函數
index.php
Object.php
output:
IMooc\Object string(8) "helloJiu"