0

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.

vbd
  • 3,437
  • 4
  • 32
  • 45

2 Answers2

3

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

knittl
  • 246,190
  • 53
  • 318
  • 364
2

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

echo $fanr->_attributes['value'];
cletus
  • 616,129
  • 168
  • 910
  • 942