what is the difference between these two ECHO statements:
$test = "30cm";
$newtest = $test + "40cm";
//first echo version
echo "Your imaginary box has a width of $newtest centimeters";
//second echo version
echo "your imaginary box has a width of " . $newtest . " centimeters";
OUTPUT:
Your imaginary box has a width of 70 centimetersYour imaginary box has a width of 70 centimeters
it seems like their output is the same..... but when I added "cm" in the first echo version:
//fist echo version
echo "Your imaginary box has a width of $newtestcm centimeters";
this is what the browser displayed:
OUTPUT:
Your imaginary box has a width of centimetersyour imaginary box has a width of 70 centimeters
The number 70 was not displayed....I don't understand it... Also, the statement of the first version of echo, I write it in a manner that it is executed as one string, so I expected that instead of printing 70, it will print $newtest, but it doesn't seem to be that way...... Can somebody explain to me this?



Reply With Quote

Bookmarks