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 trialNipun Tharuksha
487 Pointswhen i submit the task 3 it says that task 2 no longer passing. Could anyone can explain this error for me please
when i submit the task 3 it says that task 2 no longer passing. Could anyone can explain this error for me please
<?php
//Place your code below this comment
$integerOne = 1;
$integerTwo = 2;
$integerOne += 5;
$integerTwo -= 1;
$floatOne = 1.5;
$integerOne *= $floatOne ;
echo $floatOne;
?>
2 Answers
Jennifer Nordell
Treehouse TeacherHi there! The most common reason this will happen is because of a syntax error. However, you've run into one of those rather rare scenarios in which you've changed the value of a variable which you weren't supposed to change. In the third step, you are supposed to echo out directly the result of multiplying $integerOne
with $integerTwo
. But you've replaced the value of $integerOne
with that result and then echoed it out.
Imagine that I add this line to the instructions: Do this without changing the values of any of the variables from the previous steps.
I think you can get it with these hints, but let me know if you're still stuck!
Nipun Tharuksha
487 Pointswell now the image is clear.Thank you very much.
Nipun Tharuksha
487 PointsNipun Tharuksha
487 PointsThanks for your reply. But the thing is that still i dont understand the reason for error. So could you please explain me it more and please include the right code in your comment if you can.
Regards, Nipun
Nipun Tharuksha
487 PointsNipun Tharuksha
487 PointsDear I changed the code as follow and now its working .But I really dont have a clear image about this process.
$multiply = $integerOne * $floatOne;
echo $multiply ;
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi there! The challenge also doesn't ask you to use a new variable. It wants you to echo out the value directly like this:
echo $integerOne * $floatOne;
The reason you got the error to begin with was because you had this line:
$integerOne *= $floatOne ;
This line takes integerOne and multiplies it by floatOne, then assigns the result back into integerOne. This means that although the value of integerOne should be 6, it is now 9.