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

Louise Turner
Louise Turner
710 Points

I believe my question is correct. My variable $floatOne is a float with a value of 1.5

Why is my test not passing?

index.php
<?php

//Place your code below this comment
$integerOne = 1;
$integerTwo = 2;

$integerOne = $integerOne + 5;

var_dump ($integerOne);
var_dump (--$integerTwo);

$floatOne = 1.5;
var_dump ($floatOne);
echo $floatOne;
echo ' multiplied by ';
echo $integerOne;
$floatOne = $floatOne * $integerOne;
echo ' = ';
echo $floatOne;
?>

1 Answer

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

Hi there! Not quite. At this point, your $floatOne is now equal to 9 instead of 1.5. And your code actually proves it. The last thing you echo out is the value of $floatOne and the result is 9.

This is the line that is causing this:

$floatOne = $floatOne * $integerOne;

This takes the value of $floatOne (which is 1.5 at this point) and multiplies it by the value of $integerOne which is 6. The result is 9. The 9 is assigned back into $floatOne overwriting its previous value.

Here's a quote from the instructions:

After adding 5 to $integerOne, and without further changes to the value of $integerOne or $floatOne, multiply $integerOne by $floatOne and display the results.

But by writing over the value of $floatOne, you've made a "further change".

Try echoing out your results directly like this:

echo $floatOne * $integerOne;

Also, it's important to note that you have a series of var_dumps and echoes in your code which are not called for and may cause problems. Echo out only what is asked for.

Hope this helps! :sparkles: