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 PHP Basics Unit Converter Manipulating Numbers

Marlena Coutlee
Marlena Coutlee
1,263 Points

Hi, I don't know what I am doing wrong in this question.

I have tried different ways but nothing seems to work and I can't move on until I get this right.

I am trying to echo my answer after multiplying two variables together at the very bottom but I keep getting an error that I'm not echoing and to stop using var_dump. But I'm not using var_dump. So confused :S

index.php
<?php

//Place your code below this comment
$integerOne = 1;
$integerOne = $integerOne + 5;
var_dump($integerOne);

$integerTwo = 2;
var_dump($integerTwo --);

$floatOne = 1.5;


$integerOne = 6;
$floatOne = 1.5;
echo $integerOne * $floatOne;

?>

3 Answers

Shayne Laufenberg
Shayne Laufenberg
4,213 Points

Lets take it step by step on what to do for this Challenge. First we need to declare all the variables that have been asked of us and set the values equal to what is needed. So (integerOne, integerTwo, floatOne) need to be set to (1, 2, and 1.5). Then we need to change them as asked of us by the instructions. Increase integerOne by 5, and increase integerTwo by 1. Then we need to display integerOne * floatOne so we use echo and in parenthesis we evaluate our expression. I've posted the solution below how to properly go about doing so and hopefully it helps you see where you went wrong :)

Solution:

<?php

// Declare & Set Variables //
$integerOne = 1;
$integerTwo = 2;
$floatOne = 1.5;

// Change Variables //
$integerOne += 5;
$integerTwo -= 1;

// Display Result //
echo ($integerOne * $floatOne);

?>
Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You started off pretty well, but then got turned around a bit somehow. And yes, your code includes two var_dumps. The third step will not pass if there is a var_dump anywhere in your code. The line $integerOne = 6; is entirely unnecessary as this is already equal to 6. The problem here, is that $integerTwo is supposed to be equal to 1 at this point. In Step 2 you were supposed to set it to 2 and then subtract 1. This was to be done the same way you added 5 to $integerOne of your code on line 5. Also you set $floatOne to 1.5 not once, but twice. While this may not be causing the challenge to fail, it is still entirely uneccessary.

Here's what I did to make your code pass. I removed the var_dumps. I added back in the line that will subtract 1 from $integerTwo. I also removed the unneeded $integerOne = 6; and the extra $floatOne = 1.5;. When I did that, your code passes! :sparkles:

Marlena Coutlee
Marlena Coutlee
1,263 Points

Thanks so much for the help on getting the answer! I wish the second task told me I didn't need var_dumps, it passed me while using them.

Oh well, thank you again for your help!