php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50004 Allow constructions like func()[0]
Submitted: 2009-10-26 18:45 UTC Modified: 2009-10-26 18:52 UTC
From: melfar at gmail dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5.3.0 OS: agnostic
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: melfar at gmail dot com
New email:
PHP Version: OS:

 

 [2009-10-26 18:45 UTC] melfar at gmail dot com
Description:
------------
PHP parser doesn't allow for array index operation to be used on a 
result of a function call.  I propose a patch to allow such a 
construction.

Reproduce code:
---------------
<?php
  function car_brands() {
    return array("chevy", "hummer");
  }
  print car_brands()[1] . "\n";
?>


Expected result:
----------------
"hummer"



Actual result:
--------------
Parse error: syntax error, unexpected '[' in test.php on line 5

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-26 18:52 UTC] melfar at gmail dot com
Duplicate of bug 50003
 [2009-10-26 18:52 UTC] melfar at gmail dot com
Closing
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 18:01:29 2024 UTC