Req #11063 [Sus->Csd]: $var = function_returning_array(args)[0]; doesn't work
| From: | nikic@php.net | Date: | Wed, 11 Apr 2012 12:08:47 +0000 |
| Subject: | Req #11063 [Sus->Csd]: $var = function_returning_array(args)[0]; doesn't work | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-169435@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=11063&edit=1
ID: 11063
Updated by: nikic@php.net
Reported by: jeremy at deadbeef dot com
Summary: $var = function_returning_array(args)[0]; doesn't
work
-Status: Suspended
+Status: Closed
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Windows NT 4.0 Build 1381
PHP Version: 4.0.4pl1
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Closing as this was implemented in PHP 5.4.
Previous Comments:
------------------------------------------------------------------------
[2001-05-23 17:37:21] jeremy at deadbeef dot com
I think that $var=(function_returning_array(args))[0]; should also work, but it does not either.
The real problem here is that the [] operator works only on variables, not on general expressions.
Just trying to make php more c-like in it's expression syntax.
------------------------------------------------------------------------
[2001-05-23 17:33:22] derick@php.net
This syntax does not make sense at all (to me). It is not present in any language AFAIK.
A function simply returns an array, and if you want to do something with that, do it later.
However, it is a valid feature request, but I don't think it wil be implemented in short time.
Changed type to Feature Request and status to Suspended.
Derick
------------------------------------------------------------------------
[2001-05-23 16:35:48] jeremy at deadbeef dot com
$var = function_returning_array(args)[0];
gives an error but
$var = function_returning_array(args);
$var=$var[0];
works fine. I think that either should work.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=11063&edit=1