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

Teacher Russell
Teacher Russell
16,873 Points

Create a New Float Variable named $floatOne with a value of 1.5. After adding 5 to $integerOne..

The questions are more confusing than the task we're asked to complete. Who out there knows what they're asking for? How can we figure out what we're doing wrong with no clues, as to where we're going wrong? What's written after "Bummer" usually just confuses me more.

index.php
<?php

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

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

?>
Ezra Siton
Ezra Siton
12,644 Points

Hi, see the correct answer below.

Work with some PHP compiler and see your results VS the task result (you can also use the challenge "preview" button but compiler is more dynamic)

In your code, you get 6 (echo $integerOne value). But you should get 9 (6 * 1.5)

1 Answer

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

Hi there! Let's take a look at part of the instructions.

... multiply $integerOne by $floatOne and display the results.

Your code echoes $integerOne. Then you go on to multiply $integerOne and $floatOne. But that's the part you're supposed to be echoing out. Also, even though it does the multiplication, the result is never stored or displayed.

So if we combine your last two lines:

echo $integerOne * $floatOne;

... it will echo out the result of that multiplication to the page per challenge instructions.

Hope this clarifies things! :sparkles:

Teacher Russell
Teacher Russell
16,873 Points

Thanks again. Strange things happen to the brain after sitting and studying coding for several hours at a time:)