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

Vince Roszak
Vince Roszak
588 Points

Cant figure why my code is not working. Please Help!!

The task is to: Create a New Float Variable named $floatOne with a value of 1.5. After adding 5 to $integerOne, and without further changes to the value of $integerOne or $floatOne, multiply $integerOne by $floatOne and display the results. The error is saying to use echo instead of using var_dump but I am using echo.

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);

$floatOne = 1.5;
echo $integerOne * $floatOne;

?>

1 Answer

Jessica Foster
Jessica Foster
6,950 Points

Hi Vince,

Let's take this step by step.

The first task says: Create Two Integer Variables - The first will be named $integerOne with a value of 1 and the second will be named $integerTwo with a value of 2.

You did this correctly. Great job!

Ok, the next task says: Add 5 to $integerOne. Subtract 1 from $integerTwo.

This is where you got into a little trouble. You don't need to var_dump here. Simply perform the arithmetic operations and store them in the variables, like this:

<?php
$integerOne += 5; // I'm using combined operators, but you can also write it out like you did.
$integerTwo -= 1;
?>

The final task says: Create a New Float Variable named $floatOne with a value of 1.5. After adding 5 to $integerOne, and without further changes to the value of $integerOne or $floatOne, multiply $integerOne by $floatOne and display the results.

You also got this right. Once you get rid of the var_dump's earlier, you should be able to complete the challenge successfully.

If you have any more questions, feel free to ask!

Cheers, Jess