Req #60408 [Com]: Array/String element access on instantiation (same like class member in 5.4RC)
| From: | lunter at interia dot pl | Date: | Wed, 30 Nov 2011 08:40:17 +0000 |
| Subject: | Req #60408 [Com]: Array/String element access on instantiation (same like class member in 5.4RC) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-165578@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60408&edit=1
ID: 60408
Comment by: lunter at interia dot pl
Reported by: bugzilla33 at gmail dot com
Summary: Array/String element access on instantiation (same
like class member in 5.4RC)
Status: Open
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 5.4.0RC2
Block user comment: N
Private report: N
New Comment:
I'm all for it.
example: short switch/case alternative
--------------------------------------
<?php
echo 'ABC'[$i]
// or
echo ['A','B','C'][$i]
?>
is equivalent to long:
<?php
switch ($i) {
case 0:
echo "A";
break;
case 1:
echo "B";
break;
case 2:
echo "C";
break;
}
?>
Previous Comments:
------------------------------------------------------------------------
[2011-11-30 07:47:07] bugzilla33 at gmail dot com
/Summary change/ Array -> Array/String
------------------------------------------------------------------------
[2011-11-30 07:36:07] laruence@php.net
support (of course).
yes, but it need to be disscussd first ;)
------------------------------------------------------------------------
[2011-11-30 07:29:12] bugzilla33 at gmail dot com
>> echo array(1, 2, 3)[0]; //output 1
>> echo "foobar"[2]; //output o
>> echo "foobar"["foo"][0] // output f
>> works.
Excellent! Have you tested it with short array constructor?
echo [1, 2, 3][0]; //output 1
Are there any opportunities to make it public in the final PHP 5.4?
------------------------------------------------------------------------
[2011-11-30 06:04:19] laruence@php.net
see https://wiki.php.net/rfc/constdereference
------------------------------------------------------------------------
[2011-11-29 14:42:50] bugzilla33 at gmail dot com
(edit summary)
------------------------------------------------------------------------
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
https://bugs.php.net/bug.php?id=60408
--
Edit this bug report at https://bugs.php.net/bug.php?id=60408&edit=1