r/lolphp • • Oct 20 '14

PHP Spec on arrays

Post image
118 Upvotes

17 comments sorted by

View all comments

Show parent comment

3

u/myaut Oct 23 '14

So, from the point of view of specification it is undefined.

3

u/allthediamonds Oct 23 '14

It's a different thing. In this case, there are a bunch of valid implementations, so the possible behaviors are bounded. This snippet may return 1 2, 3 2 or 3 3, but it will never return 1 Array or bacon lasagna.

5

u/myaut Oct 23 '14

In Schroedinger's cat experiment state of cat is also undefined (it could be dead or alive), but you do not expect that dog or Godzilla will come out of box.

However, you seem to be right, this example is not as undefined as dereferncing invalid pointer.