array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'class.reflectionproperty.php', 1 => 'ReflectionProperty', ), 'up' => array ( 0 => 'book.reflection.php', 1 => '反射', ), 'prev' => array ( 0 => 'reflectionparameter.tostring.php', 1 => 'ReflectionParameter::__toString', ), 'next' => array ( 0 => 'reflectionproperty.clone.php', 1 => 'ReflectionProperty::__clone', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/reflection/reflectionproperty.xml', ), 'extra_header_links' => array ( 'rel' => 'alternate', 'href' => '/manual/en/feeds/class.reflectionproperty.atom', 'type' => 'application/atom+xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5, PHP 7, PHP 8)
ReflectionProperty 类报告有关类属性的信息。
属性名。只读,在尝试赋值的时候抛出 ReflectionException。
定义的属性所在的类。只读,在尝试赋值的时候抛出 ReflectionException。
ReflectionProperty::IS_STATIC
表示 static 属性。在 PHP 7.4.0 之前,值为 1
。
ReflectionProperty::IS_READONLY
表示 readonly 属性。自 PHP 8.1.0 起可用。
ReflectionProperty::IS_PUBLIC
表示 public 属性。在 PHP 7.4.0 之前,值为 256
。
ReflectionProperty::IS_PROTECTED
表示 protected 属性。在 PHP 7.4.0 之前,值为 512
。
ReflectionProperty::IS_PRIVATE
表示 private 属性。在 PHP 7.4.0 之前,值为 1024
。
注意:
这些常量的值可能会在不同 PHP 版本间发生更改。建议始终使用常量而不直接依赖值。
版本 | 说明 |
---|---|
8.0.0 | 已移除 ReflectionProperty::export()。 |