Concatenation doesn’t work with addition and subtraction? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Concatenation doesn’t work with addition and subtraction?

It works with multiplication and division, though. What am I doing wrong? https://code.sololearn.com/w9oUC7NfdxMP/?ref=app

18th Oct 2018, 11:10 AM
Natália Klenovská
2 Answers
+ 6
Operator will be in double quotes and before and after that (.) will be used https://code.sololearn.com/wz9Jl2a2bb5Y/?ref=app
18th Oct 2018, 11:24 AM
GAWEN STEASY
GAWEN STEASY - avatar
0
Thanks for the fast reply, Gawen. With your answer I got an output “Addition: 4+7” I would like to know: is it possible to echo a text with addition and have the *text and the result* as an output? It works with * and / <?php echo "Multiplication: ".$numA * $numZ.'<br />'; // output: Multiplication: 28 ?> However, I can’t get a result with concatenation and + and -. <?php echo "Addition: ".$numA + $numZ."<br />"; // output: 7 // instead of: Addition: 11 ?> Thanks
20th Oct 2018, 6:38 AM
Natália Klenovská