(PHP 5, PHP 7)
ReflectionClass::getDefaultProperties — 锟斤拷取默锟斤拷锟斤拷锟斤拷
锟斤拷取锟斤拷锟侥拷锟斤拷锟斤拷裕锟斤拷锟斤拷锟斤拷思坛械锟斤拷锟斤拷裕锟斤拷锟�
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" }