我有一个对象,其中包含一些受保护的属性,我想获取和设置它们。该对象如下所示:
Fields_Form_Element_Location Object
(
[helper] => formText
[_allowEmpty:protected] => 1
[_autoInsertNotEmptyValidator:protected] => 1
[_belongsTo:protected] =>
[_description:protected] =>
[_disableLoadDefaultDecorators:protected] =>
[_errorMessages:protected] => Array
(
)
[_errors:protected] => Array
(
)
[_isErrorForced:protected] =>
[_label:protected] => Current City
[_value:protected] => 93399
[class] => field_container field_19 option_1 parent_1
)
我想获取对象的 value
属性。当我尝试使用 $obj->_value
或 $obj->value
时,会生成错误。我搜索并找到了使用 PHP反射类
的解决方案。它在我的本地上工作了,但在服务器上,PHP版本是 5.2.17
,因此我无法在那里使用此函数。有没有任何解决方案可以获得这样的属性?