php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #43486 Be able to use following format: $class->function()[index]
Submitted: 2007-12-03 15:42 UTC Modified: 2007-12-03 15:59 UTC
From: sbbritton911 at hotmail dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 5.2.5 OS: Debian
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: sbbritton911 at hotmail dot com
New email:
PHP Version: OS:

 

 [2007-12-03 15:42 UTC] sbbritton911 at hotmail dot com
Description:
------------
In using inline functions that return arrays, please make php capable of using values stored at particular indexes.  For example, $class->function_call()[index] or ($class->function_call())[index].  Basically, the same use as other langauges.

Thank you for your time.

Sincerely,

Scott B Britton

Reproduce code:
---------------
class test {
    private $scott = array("Scott", "B", "Britton");

    public function return_scott() {
        return $this->scott;
    }
}

$s = new test();

printf("%s", $s->return_scott()[0]);


Expected result:
----------------
I expected to see "Scott" printed to the screen

Actual result:
--------------
Syntax error, unexpected '['

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-12-03 15:59 UTC] derick@php.net
This has been brought up many times - it's not going to happen.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Sep 20 02:00:01 2025 UTC