用法
get_class_vars ( $class_name );
定義和用法
此函數獲取給定類的默認屬性。返回類的默認公共屬性的關聯數組。
參數
Sr.No | 參數及說明 |
---|---|
1 |
class_name(Required) 類名稱。 |
返回值
它返回類的默認公共屬性的關聯數組。生成的數組元素采用 varname => value 的形式。
示例
下麵是這個函數的用法~
<?php
class helloworld {
var $var1;
var $var2 = "xyz";
var $var3 = 100;
private $var4; // PHP 5
function helloworld() {
$this->var1 = "foo";
$this->var2 = "bar";
return true;
}
}
$hello_class = new helloworld();
$class_vars = get_class_vars(get_class($hello_class));
foreach ($class_vars as $name => $value) {
echo "$name:$value \n";
}
?>
它將產生以下結果 -
var1: var2:xyz var3:100
相關用法
- PHP get_class_vars()用法及代碼示例
- PHP get_class_methods()用法及代碼示例
- PHP get_class()用法及代碼示例
- PHP get_called_class()用法及代碼示例
- PHP get_resource_type()用法及代碼示例
- PHP get_declared_interfaces()用法及代碼示例
- PHP get_resource_id()用法及代碼示例
- PHP get_headers()用法及代碼示例
- PHP get_object_vars()用法及代碼示例
- PHP get_browser()用法及代碼示例
- PHP get_html_translation_table()用法及代碼示例
- PHP get_parent_class()用法及代碼示例
- PHP get_defined_vars()用法及代碼示例
- PHP get_declared_classes()用法及代碼示例
- PHP get_meta_tags()用法及代碼示例
- PHP getimagesizefromstring()用法及代碼示例
- PHP getservbyport()用法及代碼示例
- PHP gethostnamel()用法及代碼示例
- PHP getcwd()用法及代碼示例
- PHP getcwd( )用法及代碼示例
注:本文由純淨天空篩選整理自 PHP - Function get_class_vars()。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。