Req #60408 [PATCH]: Array/String element access on instantiation (same like class member in 5.4RC)
| From: | laruence@php.net | Date: | Wed, 30 Nov 2011 09:45:33 +0000 |
| Subject: | Req #60408 [PATCH]: 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-165581@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
Patch added by: laruence@php.net
Reported by: bugzilla33 at gmail dot com
Summary: Array/String element access on instantiation (same
like class member in 5.4RC)
Status: Assigned
Type: Feature/Change Request
Package: Scripting Engine problem
PHP Version: 5.4.0RC2
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
The following patch has been added/updated:
Patch Name: req60408.patch
Revision: 1322646333
URL: https://bugs.php.net/patch-display.php?bug=60408&patch=req60408.patch&revision=1322646333
Previous Comments:
------------------------------------------------------------------------
[2011-11-30 08:55:21] laruence@php.net
Dmitry, could you look at this please? thanks
patch and test list in: https://wiki.php.net/rfc/constdereference
All existing test passed.
------------------------------------------------------------------------
[2011-11-30 08:40:17] lunter at interia dot pl
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;
}
?>
------------------------------------------------------------------------
[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?
------------------------------------------------------------------------
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