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 trialKer Sing Tan
10,573 PointsCan you spot this php error?
Challenge: Multiply $integerOne by $floatOne and display the results.
Error: Dont change the value of $integerOne ( I could not think another way)
<?php
//Place your code below this comment
$integerOne= 1;
$integerTwo= 2;
$floatOne= 1.5;
$integerOne += 5;
echo $integerOne;
$integerOne = $integerOne * $floatOne;
echo $integerOne;
echo --$integerTwo;
?>
<?php
//Place your code below this comment
$integerOne= 1;
$integerTwo= 2;
$floatOne= 1.5;
$integerOne += 5;
echo $integerOne;
$integerOne = $integerOne * $floatOne;
echo $integerOne;
echo --$integerTwo;
?>
1 Answer
calp
10,317 PointsHello, you were very close to completing the challenge. The problem is that instead of just displaying the answer of $integerOne * $floatOne, you are setting the value of $integerOne to $integerOne * $floatOne.
To fix remove this error and pass the challenge you simply need to echo out the answer of $integerOne * $floatOne.
Here is the PHP code that will achieve what you're looking for.
<?php
//Place your code below this comment
$integerOne = 1;
$integerTwo = 2;
$floatOne = 1.5;
$integerOne += 5;
$integerTwo -= 1;
echo $integerOne * $floatOne;
?>