[精讚] [會員登入]

[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
你可能有興趣

[Rocky9] 安裝node.js 18, node.js 20

原本的nodejs16在使用 quasar dev時出現錯誤,得升級成18版以上

[SSL] Could not read certificate from server.cer 的錯誤排除

在轉換ssl憑證時,出現無法讀取的錯誤,可是怎麼看憑證都很正常,該怎麼解決?

[Linux] 如何能知道我是什麼時候安裝系統的?

linux想知道什麼時候裝系統的? 不必憑記憶。

地圖填色的網站

我們想為國家填色不需要小畫家,這個網站能幫助你

[Linux] 列出所有目錄及所占空間的方法

想知道目錄下的所有目錄所占的空間大小?

[Linux] grep 排除特定字串

使用 -v 參數可以讓grep排除特定字串的方法