I recently started learning PHP and I'm a bit confused about how to use a sign plus (+) in a PHP variable and get the desired result. I've tried searching online for an answer, but I haven't been able to find a clear explanation.
To give you some context, let's say I have a variable called $num1, which stores the value 5, and another variable called $num2, which stores the value 10. Now, I want to add these two variables together using the sign plus and store the result in a new variable called $sum.
I tried using the following code:
$sum = $num1 + $num2;
But when I echo the $sum variable, it just displays '15' instead of the expected sum of 5 and 10, which is 15. I'm not sure what I'm doing wrong here.
Could someone please explain how to properly use the plus sign in a PHP variable to achieve the desired result? Am I missing any important syntax or concept here?
Any help would be greatly appreciated. Thank you in advance!