rfc:constdereference

This is an old revision of the document!


RFC: Const array/string dereference

Introduction

A little improvement to make things consistent.

Proposal

base on feature request: https://bugs.php.net/bug.php?id=60408:

Please add array constructor dereferencing support

like JavaScript, C# and all languages excluding PHP 5.4

<?php

 $i=0;
 print(array('pa','th')[$i++]); // pa
 print(['wa','ss'][$i++]); // ss

?>

I wrote a patch to make php support const array/string dereference

after patched, following script:

echo array(1, 2, 3)[0]; //output 1
echo "foobar"[2]; //output o
echo "foobar"["foo"][0] // output f
 
echo [1,3,4][2]; //output 4

works.

Vote

Do you want this feature in PHP 5.4
Real name yes no
arpad (arpad)  
cataphract (cataphract)  
derick (derick)  
felipe (felipe)  
gwynne (gwynne)  
iliaa (iliaa)  
klaussilveira (klaussilveira)  
laruence (laruence)  
levim (levim)  
pajoye (pajoye)  
pierrick (pierrick)  
rasmus (rasmus)  
rdohms (rdohms)  
salathe (salathe)  
stas (stas)  
tyrael (tyrael)  
Count: 11 5

Patches

Tests

Changelog

  • 2011-11-30 Xinchen Hui: Initial RFC creation
  • 2011-12-13 Xinchen Hui: Start voting
rfc/constdereference.1323756811.txt.gz · Last modified: 2017/09/22 13:28 (external edit)