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 trialAbdul Zainos
4,938 PointsStuck on a code challenge: PHP Arithmetic (Multiplication)
Having a bit of trouble on the last portion of this task.
<?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);
?>
2 Answers
Corey Cramer
9,453 PointsI'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;
?>
Corey Cramer
9,453 PointsYou're very close. There's no need to include the parenthesis for your echo statement.
echo $integerOne * $floatOne;
Abdul Zainos
4,938 PointsI'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?
Corey Cramer
9,453 PointsInteresting. 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;
?>
Abdul Zainos
4,938 PointsCorey 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!
Matt Borgman
18,313 PointsMatt Borgman
18,313 PointsAbdul, 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.