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

Todd Tate
Todd Tate
540 Points

Am I right or is this a bug?

I just started paying for this and have been stuck on this LAST question on this quiz section.

I want to know if this is a bug

Challenge:

Create a New Float Variable named $floatOne with a value of 1.5. Without changing the value of $integerOne or $floatOne, multiply $integerOne by $floatOne and display the results.

My answer:

<?php //Place your code below this comment $integerOne = 1; $integerTwo = 2; $integerOne = $integerOne +5; var_dump ($integerOne); $integerTwo = $integerTwo -1; var_dump ($integerTwo); $floatOne = 1.5; var_dump ($floatOne * $integerOne); echo ($floatone); ?>

Thanks!

3 Answers

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

Hi there! It's not a bug. You're using var_dump to display all information regarding that variable including both the type and the value. It's wanting you to use echo to display the value of the variable to the page. Give it another shot with this hint in mind! :sparkles:

edited for additional note

As a side note: it's important when doing these challenges to try not to do anything the challenge doesn't explicitly ask for. Even if functional, it can cause the challenge to fail as it no longer meets the strict requirements.

Todd Tate
Todd Tate
540 Points

Thanks!

Wow I've tried that and the value of $floatOne is 9, so I've tried -7.5 and that don't work either. I;ve watched videos multiples times lol this below still will not work.

<?php //Place your code below this comment $integerOne = 1; $integerTwo = 2; $integerOne = $integerOne +5; var_dump ($integerOne); $integerTwo = $integerTwo -1; var_dump ($integerTwo); $floatOne = 1.5; $floatOne = $floatOne * $integerOne; echo ($floatone); ?>

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

Hi again, Todd Tate! First, you still have var_dump scattered throughout your code, which the challenge doesn't require nor request. But the challenge explicitly states to not change the value of $floatOne. You have written this line:

$floatOne = $floatOne * $integerOne;

This line takes 1.5 and multiplies it by 6 then assigns the value back into $floatOne thus changing the original value from 1.5 to 9.

Here was my solution:

<?php

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

?>

Here we set up $integerOne and $integerTwo with the initial values. I used the unary operators to add 5 and subtract one from them respectively. Then we create $floatOne and set it equal to 1.5. Finally, without changing any values, we echo out the result of the multiplication of $integerOne and $floatOne.

Hope this clarifies things! :sparkles:

Todd Tate
Todd Tate
540 Points

Do you work for Treehouse?