Hi! > if it means one has to take a brief look in the manual. String offset is > *not* the same as array access. > > > What are these subtle differences?
Negative indexes, string indexes. Array offset is a variable, so it can be used by-ref, but string offset can not. You can substitute object for array access, and it would work, but not for string offset. You can do $foo[1]++ for arrays, but not for string offsets, same with assign-ops. $foo[1]="bar" works differently - for string offset, it will take only one letter. $foo[1][1] works for arrays but not string offsets. Same for []. $foo[1] = 1 would assign integer for array, but string "1" for strings. It goes deeper. For arrays, $foo[1] is a regular variable, with pretty much everything working on it that works on $foo. For strings, $foo[1] is a very special thing called "string offset", and there are a lot of things that won't work with it. So if you apply your intuition, it'd serve you fine with arrays (can I do ++ on $foo[1]? Sure, why not - it's just a variable). But for string offsets, you have to develop completely different set of rules, as it is a special entity to which regular variable rules do not apply. > I agree that different things should use different syntax. However, the > point here is that all of array access, ArrayAccess and string offset > access are really the same thing and as such should also use the same I think I demonstrated that ArrayAccess and offsets are not the same thing. At least not currently. -- Stas Malyshev smalys...@gmail.com -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php