ReflectionClass::getDefaultProperties

(PHP 5, PHP 7)

ReflectionClass::getDefaultProperties锟斤拷取默锟斤拷锟斤拷锟斤拷

说锟斤拷

public ReflectionClass::getDefaultProperties ( void ) : array

锟斤拷取锟斤拷锟侥拷锟斤拷锟斤拷裕锟斤拷锟斤拷锟斤拷思坛械锟斤拷锟斤拷裕锟斤拷锟�

Note:

This method only works for static properties when used on internal classes. The default value of a static class property can not be tracked when using this method on user defined classes.

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

默锟斤拷锟斤拷锟皆碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷缘锟斤拷锟斤拷疲锟斤拷锟街碉拷锟斤拷锟斤拷缘锟侥拷锟街碉拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫伙拷锟侥拷锟街凳憋拷锟� NULL锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷志锟教拷头蔷锟教拷锟斤拷裕锟揭诧拷锟斤拷锟斤拷强杉锟斤拷锟斤拷锟斤拷畏锟斤拷锟�

锟斤拷锟斤拷

Example #1 ReflectionClass::getDefaultProperties() 锟斤拷锟斤拷

<?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"
}

锟轿硷拷