|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-06 19:37 UTC] felipe@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 01:00:01 2025 UTC |
Description: ------------ Any construct of the form myFunc()[x] or $object->myFunc()[x] results in a fatal error, even if myFunc() returns an array. Putting the expression in parentheses (like (myFunc())[x]) doesn't help. The only remedy seems to be using an intermediate variable. Reproduce code: --------------- <?php function getArray() { return array(1, 2, 3); } echo getArray()[1]; ?> Expected result: ---------------- "2" being output Actual result: -------------- Parse error: syntax error, unexpected '[', expecting ',' or ';' in test.php on line 4