Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Gustavo Barrera
704 PointsIve been asked to echo a few arithmetic operations and for each operation I should assign its result to a new variable
$a = 8; //I have this 2 variables
$b = 14;
// it says I have to echo them and assign the result to a new variable and display it in a paragraph tag.
I have been able to echo them but I am bit confused where it says that I have to assign the results to a new variable and then display them in a paragraph tag. Can somebody explain this to me.
many thanks.
echo $a + $b;
echo $a - $b;
echo ($b - $a) * $a;
echo $b % $a;
echo $b / $a;
2 Answers
Jason Anello
Courses Plus Student 94,610 PointsWithout seeing the code challenge or the exact instructions if this is from something else, about all I can tell you is how you can store the result in another variable and echo it in a paragraph.
<?php
$c = $a + $b; // This stores the result of a + b in a new variable $c
echo "<p>" . $c . "</p>"; // This would output the $c variable in a paragraph tag.
?>
Gustavo Barrera
704 PointsThanks jason I think I got it now....
Gustavo Barrera
704 PointsJason you mean, you have not understand my question?
Jason Anello
Courses Plus Student 94,610 PointsIf this is from a code challenge then it's a good idea to post the link to the challenge so that anyone helping you can review it.
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Gustavo,
Which challenge is this?