Req #63712 [Opn->Csd]: function returning array and directly calling array element parse error
| From: | nikic@php.net | Date: | Thu, 06 Dec 2012 17:47:12 +0000 |
| Subject: | Req #63712 [Opn->Csd]: function returning array and directly calling array element parse error | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175170@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63712&edit=1
ID: 63712
Updated by: nikic@php.net
Reported by: tretoria at data dot bg
Summary: function returning array and directly calling array
element parse error
-Status: Open
+Status: Closed
Type: Feature/Change Request
Package: Compile Failure
Operating System: win32
PHP Version: 5.3.19
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
This feature was added in PHP 5.4.
Previous Comments:
------------------------------------------------------------------------
[2012-12-06 15:13:52] tretoria at data dot bg
Description:
------------
When calling function which returns array and try to get element of the returned array directly,
without copying the result into variable like "foo()[x]" where x is integer, it returns
parse syntax error.
However this is working in 5.4.* versions.
Test script:
---------------
<?php
function returnArray()
{
$arr = array("first", "second", "third");
return $arr;
}
echo returnArray()[1];
?>
Expected result:
----------------
second
Actual result:
--------------
Parse error: syntax error, unexpected '[', expecting ',' or ';'
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63712&edit=1