Consider the following line of code:
<?php $x = 10; $y = 7; echo '10 - 7 = '.$x-$y; ?>
The result of this is 3, which is the expected result of computing $ x- $ y. However, the expected result:
10 - 7 = 3
So my question is what happened to the string that I am concatenating with the calculation? I know that to get the expected result, I need to enclose the arithmetic operation in brackets:
<?php $x = 10; $y = 7; echo '10 - 7 = '.($x-$y); ?>
exits
10 - 7 = 3
But since PHP does not complain about the source code, I can only ask what is the logic of the products in this case? Where did the string go? If anyone can explain this or point me to a place in the PHP manual where this is explained, I would appreciate it.
source share