ReflectionProperty::getValue() - php 反射机制
ReflectionProperty::getValue()
(PHP 5, PHP 7)
Gets value
说明
publicReflectionProperty::getValue([object $object] ): mixedGets the property's value.
参数
$objectIf the property is non-static an object must be provided to fetch the property from. If you want to fetch the default property without providing an object useReflectionClass::getDefaultProperties()instead.
返回值
The current value of the property.
错误/异常
Throws aReflectionExceptionif the property is inaccessible. You can make a protected or private property accessible usingReflectionProperty::setAccessible().
范例
Example #1ReflectionProperty::getValue()example
以上例程会输出:
string(6) "foobar" string(6) "barfoo" string(6) "foofoo"
参见
- ReflectionProperty::setValue() Set property value
- ReflectionProperty::setAccessible() Set property accessibility
- ReflectionClass::getDefaultProperties() 获取默认属性
- ReflectionClass::getStaticPropertyValue() 获取静态(static)属性的值
To allow protected and private properties to be accessed, you should use ReflectionProperty::setAccessible(bool $accessible):
鹏仔微信 15129739599 鹏仔QQ344225443 鹏仔前端 pjxi.com 共享博客 sharedbk.com
图片声明:本站部分配图来自网络。本站只作为美观性配图使用,无任何非法侵犯第三方意图,一切解释权归图片著作权方,本站不承担任何责任。如有恶意碰瓷者,必当奉陪到底严惩不贷!