PHP PHP Basics Unit Converter Manipulating Numbers

bilal agha
seal-mask
.a{fill-rule:evenodd;}techdegree
bilal agha
PHP Development Techdegree Student 4,509 Points

Challenge Help

hello i ma facing an error in my answer. i have been trying to solve it and watched the videos again and again but can't figure out my mistakes. can someone please help me out.

index.php
<?php

//Place your code below this comment
$integerOne = 1;
$integerTwo = 2;
$floatOne = 1.5;
var_dump ( $integerOne );
var_dump ( 1);
var_dump ( $integerOne + 5);
var_dump ( $integerTwo );
var_dump ( 2);
var_dump ( $integerTwo - 1);
?>

3 Answers

Patricia Silva
PLUS
Patricia Silva
Courses Plus Student 81,340 Points

Remove the var_dumps and check your answer. If you still have an error, post again.

Patricia Silva
PLUS
Patricia Silva
Courses Plus Student 81,340 Points

This is the out from my console:

$integerOne = 1;

< 1

$integerTwo = 2; < 2

$floatOne = 1.5; < 1.5

$integerOne +=5;

< 6

$integerTwo -=1; < 1

Chad M. Crabtree
Chad M. Crabtree
3,678 Points

I had the same issue at first. The problem is that you need to actually assign the arithmetic operation to the variable you're trying to alter. Here is the correct solution:

<?php

$integerOne = 1;
$integerTwo = 2;
$floatOne = 1.5;

$integerOne = $integerOne + 5;
$integerTwo = $integerTwo - 1;

// Or you can use the shorthand version of the same thing:

$integerOne += 5;
$integerTwo -= 1;

?>

And, of course, if you wanted to display this to the console, you could do the same with var_dump():

<?php

$integerOne = 1;
$integerTwo = 2;
$floatOne = 1.5;

var_dump( $integerOne = $integerOne + 5 );
var_dump( $integerTwo = $integerTwo - 1 );

// Again, here is the shorthand:

var_dump( $integerOne += 5 );
var_dump( $integerTwo -= 1 );

?>

Hope that helps!