ReflectionClass
PHP Manual

ReflectionClass::getDefaultProperties

(PHP 5)

ReflectionClass::getDefaultPropertiesGets default properties

说明

public array ReflectionClass::getDefaultProperties ( void )

Gets default properties from a class (including inherited properties).

参数

此函数没有参数。

返回值

An array of default properties, with the key being the name of the property and the value being the default value of the property or NULL if the property doesn't have a default value. The function does not distinguish between static and non static properties and does not take visibility modifiers into account.

范例

Example #1 ReflectionClass::getDefaultProperties() example

<?php
class Bar {
    protected 
$inheritedProperty 'inheritedDefault';
}

class 
Foo extends Bar {
    public 
$property 'propertyDefault';
    private 
$privateProperty 'privatePropertyDefault';
    public static 
$staticProperty 'staticProperty';
    public 
$defaultlessProperty;
}

$reflectionClass = new ReflectionClass('Foo');
var_dump($reflectionClass->getDefaultProperties());
?>

以上例程会输出:

array(5) {
   ["staticProperty"]=>
   string(14) "staticProperty"
   ["property"]=>
   string(15) "propertyDefault"
   ["privateProperty"]=>
   string(22) "privatePropertyDefault"
   ["defaultlessProperty"]=>
   NULL
   ["inheritedProperty"]=>
   string(16) "inheritedDefault"
}

参见


ReflectionClass
PHP Manual