Rasmus Lerdorf wrote:
Andreas Korthaus wrote:
But you know without understanding of any context, that it's the 6th character of the string "$str". When you see $var[5], it could be the 6th character of a string, or an element of an array... and what about the value? You can't be sure that it's a string with length 1, it also could be another array, an object, a string with length 4711...

That increases complexity and decreases readability.

Your argument falls apart there.  Try it:

$a = array("ab","cd","ef");
echo $a{2};

Guess what that prints? {} has nothing to do with strings. They are 100% equivalent to [] and as such add nothing to clarity.
OK, but by dropping {} for strings you also remove the possibility to have a convention like "[] for arrays and {} for strings". If I could decide I would drop {} for arrays and [] for strings, but I fear I will not be asked to decide... ;-)

Best regards
Andreas

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to