Short Array Syntax for PHPTweet
$var = array(1,2,3);
The proposed additional syntax is:
$var = [1,2,3];
So, I voted +1 for this feature on the PHP Internals list. A colleague asked me why I voted +1. At first I had no good answer other than it was just a gut feeling. It just feels like a good addition to the language. It is common among web languages and therefore users coming into PHP from other languages may find it more comfortable.
The best thing I could tell him was that it would make arrays fall in line with other data types in PHP. For example, you never write:
$var = int(1);
$var = string(foo);
So, why oh why do we have to have what looks like a function, but in reality is not, for creating an array? It is a language construct and should look like a language construct. I think the [ ] syntax makes more sense when you think about it in those terms.
I say commit it Andi. That seems to be what everyone else does. =)
Well i think addition is useless.
If i decide to use it and maybe customer has lower PHP version it will cause Problems so i have to use old codes anyway.
Disadvantag 2, if Developers who do not read all PHP news anyday see mit code they might not know what it is.