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

multiply integer by float

Multiply $integerOne by $floatOne and display the results ??? $integerOne = 6; $floatOne = 1.5;

index.php
<?php
$integerOne = 1;
$integerTwo = 2;
$floatOne = 1.5;
$integerOne += 5;
echo $integerOne;
$integerTwo--;
echo $integerTwo;
echo $floatOne * $integerOne ;
?>

2 Answers

jamesjones21
jamesjones21
9,260 Points

you need to create a new variable and then assign it $integerOne * $floatOne

Like so:

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

Thank u bro

You just need to make sure that your script only includes things that the tasks have asked for. The way you're multiplying is fine

Let me know if this helps here

jamesjones21
jamesjones21
9,260 Points

the above code I did actually passed the challenge, I guess you marked it down as not worthy?

Based on what the tasks say to do I don't think your answer is that great. It's all good, tho.

jamesjones21
jamesjones21
9,260 Points

as mentioned only include what the task is asking for, which is what the solution above does. If you think its bad, then why not elaborate and provide an answer.....

The third task never asks for a new variable to be created. It just asks for the multiplication to be echo'd out.

jamesjones21
jamesjones21
9,260 Points

it may have not mentioned to create a new variable but least it's held in a variable so that it makes it easier to read, just my approach to doing it.

thanks again :)

np! You can mark this question as solved by selecting a "best answer". :smile: