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 trialElizabeth Bockmeyer
1,938 PointsI don't understand what I am doing incorrectly
<?php
//Place your code below this comment
$integerOne = 1;
$integerTwo = 2;
//add 5 to intergerOne
$integerOne = $integerOne + 5;
//Subtract 1 from $integerTow
$integerTwo = $integerTwo - 1;
$floatOne = 1.5;
$integerOne = ($integerOne * $floatOne);
echo $integerOne;
?>
Iain Simmons
Treehouse Moderator 32,305 PointsUpdated to change topic to PHP and add code in code blocks.
2 Answers
Steven Parker
231,172 PointsThe trick is in the instructions.
You didn't provide a link, but I believe I have identified the challenge you are working on as Manipulating Numbers.
Task 3 of the challenge says: "... and without further changes to the value of $integerOne or $floatOne, multiply $integerOne by $floatOne and display the results.", but your code multiplies those numbers and assigns the result back to $integerOne. So instead of making that assignment, you should just echo the result of the multiplication itself.
Shaun Dixon
10,944 PointsI think the issue you are experiencing is being caused by the variables you are declaring, being on the same line as the comments.
Try this:
<?php
//Place your code below this comment
$integerOne = 1; $integerTwo = 2;
//add 5 to intergerOne
$integerOne = $integerOne + 5;
//Subtract 1 from $integerTow
$integerTwo = $integerTwo - 1;
$floatOne = 1.5;
$integerOne = ($integerOne * $floatOne);
echo $integerOne; ?>
Anything on the same line as the // will be classed as a comment and not parsed by PHP.
Steven Parker
231,172 PointsNote Since Elizabeth did not use Markdown to format the code, that code might not actually be on the same line as the comments.
UPDATE: Now that Iain has formatted it, my suspicion has been confirmed.
Steven Parker
231,172 PointsSteven Parker
231,172 PointsThis looks like PHP code. Did you mean to put this question in the PHP category instead of JavaScript? If so, you can change the topic using "Edit Question".
Also, when posting code, please use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area.