函數 | 說明 |
---|---|
array get_object_vars(object $object) | $object 為物件。 |
參數 (parameter) 為物件變數,須注意回傳的是陣列。
舉例如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | <?php class Apple { private $a ; public $b = 1; public $c ; protected $d = 2; static $e ; public function test() { var_dump(get_object_vars( $this )); } } $test = new Apple(); var_dump(get_object_vars( $test )); $test ->test(); /* 《程式語言教學誌》的範例程式 檔名:object10php 功能:示範 PHP 程式 作者:張凱慶 時間:西元 2013 年 2 月 */ ?> |
執行結果如下

中英文術語對照 | |
---|---|
函數 | function |
陣列 | array |
參數 | parameter |
您可以繼續參考
類別、物件相關函數
相關目錄
回 PHP 快速導覽
回 PHP 教材
回首頁
參考資料
http://www.php.net/manual/en/function.get-object-vars.php
沒有留言:
張貼留言