#43768 [Opn->Bgs]: Using [] operator on an array returned by a function call throws fatal error

From: Date: Sun, 06 Jan 2008 19:37:20 +0000
Subject: #43768 [Opn->Bgs]: Using [] operator on an array returned by a function call throws fatal error
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-121083@lists.php.net to get a copy of this message
ID: 43768 Updated by: felipe@php.net Reported By: roan dot kattouw at home dot nl -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: any PHP Version: 5.2.5 New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php See http://bugs.php.net/bug.php?id=43577 Previous Comments: ------------------------------------------------------------------------ [2008-01-06 15:10:47] roan dot kattouw at home dot nl 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 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43768&edit=1

« previous php.bugs (#121083) next »