This question already has an answer here:
I am trying to study PHP. Suppose i have two variable
$A=5;
$B=10;
then i want to print the sum as Sum = 15
for that i wrote
echo "Sum=".$A+$B;
But i am getting only the value of $B. that means my result is
10
What is the error in my printing statement?
</div>
You need to check for the operator precedence over here you statement'll be evaluated as
echo ("Sum=".$A)+$B;
instead you need to write it like as
echo "Sum=".($A+$B);
or you can write it like as
echo "Sum=",$A+$B;