开发者

Accessing array value

开发者 https://www.devze.com 2022-12-10 01:32 出处:网络
print_r($fanr); results in: HTML_QuickForm_text Object ( [_label] => FA-Nummer [_type] => text [_flagFrozen] =>

print_r($fanr);

results in:

HTML_QuickForm_text Object
(
    [_label] => FA-Nummer
    [_type] => text
    [_flagFrozen] => 
    [_persistantFreeze] => 1
    [_attributes] => Array
        (
            [name] => auftragsnr
            [type] => text
            [value] => 123
        )

    [_tabOffset] => 0
    [_tab] =>   
    [_lineEnd] => 

    [_comment] => 
)

trying to output the value of name with

echo $fanr["_attributes"]["value"];

Did not work. The error.log tells me

[Tue Oct 27 13:58:08 2009] [error] [client 127.0.0.1] PHP Fatal error:  Cannot use object of type HTML_QuickForm_text as开发者_Go百科 array in C:\\htdocs\\apps\\u-antrag\\upload_form.php on line 97

Please, tell me where I made the mistake.


your variable $fanr is an object, not an array. you have to use $fanr->_attributes['value'] to access its members.

alternatively you can implement the ArrayAccess interface


$fanr is an object not an array. As such, use the -> operator to access members.

echo $fanr->_attributes['value'];
0

精彩评论

暂无评论...
验证码 换一张
取 消