How can I print an operation of two variables in PHP? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How can I print an operation of two variables in PHP?

I have already tried echo "The result is $(($num1 + $num2)) ..... isn't working.

20th Sep 2020, 1:53 PM
Anurag Mondal
Anurag Mondal - avatar
7 Answers
20th Sep 2020, 3:15 PM
Prachi The Pari ⭐
Prachi The Pari ⭐ - avatar
+ 8
<?php $sum1 = 10; $sum2 = 10; echo $sum1 + $sum2; echo "<br>"; echo $sum1 * $sum2; echo "<br>"; echo $sum1 - $sum2; echo "<br>"; echo $sum1 % $sum2; ?>
20th Sep 2020, 2:24 PM
ㅤㅤㅤ
+ 4
༄ᶦᶰᵈ᭄⚔𝕌𝕛𝕛𝕒𝕨𝕒𝕝⚔ —͟͟͞͞𖣘 It wasn't working inside a " " . Had to print it after a comma. Thanks.
20th Sep 2020, 2:30 PM
Anurag Mondal
Anurag Mondal - avatar
+ 4
Owh..okay..thanks.
20th Sep 2020, 3:32 PM
Anurag Mondal
Anurag Mondal - avatar
+ 2
Please see how, here on a live example: https://code.sololearn.com/wdMg5lB9T43K/?ref=app
20th Sep 2020, 3:33 PM
JaScript
JaScript - avatar
+ 2
Remove the outer $()
21st Sep 2020, 10:32 PM
Sonic
Sonic - avatar
0
print(5_3)
21st Nov 2020, 8:52 PM
rdwan adm
rdwan adm - avatar