dongnao6858 2009-10-27 13:17
浏览 20
已采纳

访问数组值

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 array in C:\\htdocs\\apps\\u-antrag\\upload_form.php on line 97

Please, tell me where I made the mistake.

  • 写回答

2条回答 默认 最新

  • dqg2269 2009-10-27 13:19
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?