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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 23:01:32 2024 UTC