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

Stuck on a code challenge: PHP Arithmetic (Multiplication)

Having a bit of trouble on the last portion of this task.

index.php
<?php

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


$integerOne = $integerOne + 5;
var_dump($integerOne);

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

//The code below is what I'm having a bit of trouble with
$floatOne = 1.5;
echo($integerOne * $floatOne);
?>
Matt Borgman
Matt Borgman
18,313 Points

Abdul, this code appears to work for me when I put it into workspaces. Can you be more specific on what is giving you trouble? Note that the echo statement does not give a newline character on it's own, so you may be missing the output as it will come at the begging of the command prompt in workspaces.

2 Answers

I'm happy I could help!

Original: Interesting. I just went through the challenge and will put my code below. It's very similar to yours with the exception of the var_dumps and I add in a more concise format

<?php

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

$integerOne += 5;
$integerTwo -= 1;

$floatOne = 1.5;

echo $integerOne * $floatOne;
?>

You're very close. There's no need to include the parenthesis for your echo statement.

echo $integerOne * $floatOne;

I'm sorry, this didn't work. I did try it. Maybe adding the question below will help.

The question is below: 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.

I still get "Bummer! Are you sure you multiplied correctly?

Interesting. I just went through the challenge and will put my code below. It's very similar to yours with the exception of the var_dumps and I add in a more concise format

<?php

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

$integerOne += 5;
$integerTwo -= 1;

$floatOne = 1.5;

echo $integerOne * $floatOne;
?>

Corey Cramer this actually worked! Thank you for helping me optimize this! If you move your comment to an answer I'd be more than happy to mark this question answered!