Just a friendly note from my PHP user side:

    We had 2 places where {} where used for accessing string.
    Took me 10 seconds to remove those with the help of
    the nice E_STRICT error. (filename, linenumber)

    --Jani


On Thu, 17 Nov 2005, Rasmus Lerdorf wrote:


Andreas Korthaus wrote:
As far a code readability and obviousness goes, I doubt anybody would guess their way to the $str{5} syntax.

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.

-Rasmus



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

Reply via email to