Req #23022 [Bgs->Csd]: Supported dereferencing array indeces on arbitrary expressions
| From: | cataphract@php.net | Date: | Wed, 27 Oct 2010 15:11:55 +0000 |
| Subject: | Req #23022 [Bgs->Csd]: Supported dereferencing array indeces on arbitrary expressions | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-155569@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=23022&edit=1
ID: 23022
Updated by: cataphract@php.net
Reported by: mfischer@php.net
Summary: Supported dereferencing array indeces on arbitrary
expressions
-Status: Bogus
+Status: Closed
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Any
PHP Version: 5CVS-2003-04-02 (dev)
-Assigned To:
+Assigned To: cataphract
Block user comment: N
New Comment:
Marking as closed, as this has been implemented in trunk.
Previous Comments:
------------------------------------------------------------------------
[2010-02-13 12:43:48] aharvey@php.net
Closing, since for better or worse, this has since gone through the RFC
process and been declined. Cite:
http://wiki.php.net/rfc/functionarraydereferencing
------------------------------------------------------------------------
[2010-02-12 21:37:28] zeb at zebhodge dot com
I'm baffled that this doesn't work in PHP like it does in so many other
languages.
------------------------------------------------------------------------
[2009-12-31 06:26:48] billyellison99 at gmail dot com
I fully support this feature. It'd make my life a whole lot easier, and
make my code much neater and smaller.
------------------------------------------------------------------------
[2009-11-10 03:47:40] kexianbin at diyism dot com
For objects, you could hack like this:
class user
{public $username='jack';
public function __get($prop_name)
{return $this->$prop_name();
}
private function degree()
{return array('doctor', 'master');
}
}
$aUser=new user();
echo $aUser->degree[1];
------------------------------------------------------------------------
[2009-11-05 05:43:34] glennwidener at gmail dot com
I found this lack of symmetry in array references really lame too. If
an expression delivers an array, then you should be able to reference an
element of that array. The only question is operator precedence and
grouping: recommend following the C rules - primary expressions group
left to right, parenthesis disambiguate.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=23022
--
Edit this bug report at http://bugs.php.net/bug.php?id=23022&edit=1