Re: When is "z" != "z" ?
| From: | Rasmus Lerdorf | Date: | Sun, 04 Jun 2006 19:40:27 +0000 |
| Subject: | Re: When is "z" != "z" ? | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-237370@lists.php.net to get a copy of this message | ||
Martin Alterisio wrote:
Still: anything < ++anything should be true, or at least that's what they taught me on abstract data types design, and I think they're right (at least this time)In loosely typed languages that is not always true. Operators have to guess at the type and try to do what the user expects. There will always be edge cases. Being able to increment strings is pretty handy when you need to create sequences for unique file and directory names. For example, this also works: $filename = "file1"; $filename++; echo $filename; You would get "file2" from this. Think about the amount of code you would need to write in C to make that work? Then change $filename to "fileA" and increment it. And you get "fileB". When we get to "fileZ" we don't want to go off into unprintable character land, we want to try to stick with the pattern. -Rasmus