News for hackers. Stuff that matters.
Re:What PHP 5.5 might look like by sanxiyn on Thursday July 12, 2012 @11:10AM (#4234874)
As I understand, it goes like this: in PHP grammar, expressions are divided into two classes: variables, and expressions without variables. To simplify, you can think variables start with $, expressions without variables don't. These two classes are handled in completely different ways. Since array literals are expressions without variables, it isn't too strange that $x[0] parses, but [0][0] doesn't.

One reason it is like that has to do with string interpolation. PHP interpolates $x[0] inside double quotes, but does not (and probably should not) interpolate [0][0]. I am not saying this is a good solution, but hopefully that answers "how is that even possible?" question.

There are no comments on this comment yet.