|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-11-29 12:06 UTC] bugzilla33 at gmail dot com
Description:
------------
Please add array constructor dereferencing support
like JavaScript, C# and all languages excluding PHP 5.4
Test script:
---------------
<?php
$i=0;
print(array('pa','th')[$i++]); // pa
print(['wa','ss'][$i++]); // ss
?>
Expected result:
----------------
Parse error: syntax error, unexpected '[' in C:\htdocs\test.pl\array.php on line 4
Actual result:
--------------
pass
Patchesconst_dereference_002.phpt (last revision 2011-11-30 09:46 UTC by laruence@php.net)const_dereference_003.phpt (last revision 2011-11-30 09:46 UTC by laruence@php.net) const_dereference_001.phpt (last revision 2011-11-30 09:46 UTC by laruence@php.net) req60408.patch (last revision 2011-11-30 09:45 UTC by laruence@php.net) Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 30 02:00:01 2025 UTC |
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; } ?>