|
Posted by Chung Leong on 05/28/06 07:57
Norman Peelman wrote:
> It makes sense because as soon as you try to ADD a number to a 'string'
> (or a 'string' to a 'string'), the strings are lost (counted as zero):
You might as well argue that 1 + 2 * 3 should equal 9. "As soon as you
add 2 to 1, you get 3..."
Addition and multiplication are communtative operations. 1 + 6 = 6 + 1
and 2 * 3 = 3 * 2. Thanks to precedence, they maintains their
properties in more complex expression: 1 + 2 * 3 = 1 + 3 * 2 = 3 * 2 +
1.
In PHP, because . and + have the same precedence, addition is no longer
communtative: "0." . 7 + 5 yields a different result from "0." . 5 +
7. So if you will, please explain how violating elementary mathematical
principles makes sense.
[Back to original message]
|