I have a Form object $form. One of its variables is a Field object which represents all fields and is an array (e.g $this->field['fieldname']
). The getter is $form->fields()
.
To access a specific field method (to make it required or not for example) I use $form->fields()['fieldname']
which works on localhost with wamp but on the server throws this error:
Parse error: syntax error, unexpected '[' in (...)
I have PHP 5.3 on the server and because I reinstalled wamp and forgot to change it back to 5.3, wamp runs PHP 5.4. So I guess this is the reason for the error.
How can I access an object method, which returns an array, by the array key with PHP 5.3?