Re: dropping curly braces
| From: | Andreas Korthaus | Date: | Thu, 17 Nov 2005 23:26:47 +0000 |
| Subject: | Re: dropping curly braces | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-20110@lists.php.net to get a copy of this message | ||
Rasmus Lerdorf wrote:
Andreas Korthaus wrote:If I could decide I would drop {} for arrays and [] for strings, but I fear I will not be asked to decide... ;-) Best regards AndreasBut 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".