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

PHP

Gustavo Barrera
Gustavo Barrera
704 Points

Ive 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;

Hi Gustavo,

Which challenge is this?

2 Answers

Without 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
Gustavo Barrera
704 Points

Thanks jason I think I got it now....

Gustavo Barrera
Gustavo Barrera
704 Points

Jason you mean, you have not understand my question?

If 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.