HalfaBee wrote:I am sure it worked before.
Really? I'm running PHP 4.4.4 and 5.2.1, and both returned the same result. Looking at the syntax, it makes sense to me:
PHP sees the '-' operator and knows you're trying to do subtraction. Okay, so what are we subtracting? On the left side, you have a string: "diff = 39978". On the right side, you have another string: "39954" with a line break at the end.
When you try to subtract two strings in PHP, PHP attempts to convert the string into an integer by reading in numerics from the left until it reaches a non-numeric character. So, on the left it evalues the string to be 0. Therefore, the output of -39954 (or the mathematical expression 0 - 39954) is correct.
Maybe I just didn't notice, but this behavior would make sense to me in previous version of PHP as well... I don't know why they would have suddenly changed it, though maybe this is true. Either way, not using ()'s in this situation isn't a good coding practice.