[精讚] [會員登入]

[PHP] 取得物件中的方法和屬性的方法

Get the methods and properties of an object

分享完整連結 //n.sfs.tw/m10348

分享連結 [PHP] 取得物件中的方法和屬性的方法@精讚
(文章歡迎轉載,請尊重版權註明連結來源)
2017-08-10 09:21:41 By 張○○

在PHP中取得物件中元素的方法

取得方法

print_r(get_class_methods($object));

輸出範例

Array ( [0] => setItems [1] => getItems [2] => setItemsPerPage [3] => getItemsPerPage [4] => setKind [5] => getKind [6] => setNextLink [7] => getNextLink [8] => setPreviousLink [9] => __construct [10] => __get [11] => __isset [12] => __unset )

取得屬性

print_r(get_object_vars($object));

print_r(get_class_vars($object)); // X 此函數不能帶物件參數

輸出範例

Array ( [itemsPerPage] => 1000 [kind] => analytics#accounts [nextLink] => [previousLink] => [startIndex] => 1 [totalResults] => 1 [username] => user@note-176312.example.com )

 

 

END
你可能有興趣

[地理] 澳洲柏斯的位置竟然比台灣還要西邊

這近我驚奇的發現,澳洲柏斯的精度竟然比臺灣甚至今晚還要來的西邊

WarSpotting 統計俄國在烏克蘭戰爭中到底是損失了多少軍事裝備或人員

這個網站可以看到俄羅斯在戰場上的軍事人員裝備損失,非常詳細

Mac上 vim的複製貼上不能用

在freebsd系統中發現vim裡的command+c沒辦法選取複製,但command+v可以貼上

check-host 從世界各地檢查你的網站能不能連線?

檢測你的網站能不能暢通?這個網站可讓你知道你的網站是不是「網際網路」還是「區域網路」?

[Smarty4] 出現 modifiers 函式不能用的問題

當我把smarty由3版更新到4.5.1版的時候,出現了Using unregistered function xx in a template這樣的錯誤,該如何解決?

[Docker] docker中要怎麼修改影像的名稱,rename image

透過 build來的image如果沒有指定名稱,事後要怎麼修改影像的名稱?