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

I added 5 to $integerOne. It is still not passing.

Help?

index.php
<?php


//Place your code below this comment

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

?>

Hi Geet,

For task 2 your code should be

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

1 Answer

You need to sum and subtract the values to the variable.

For i.e.:

<?php
$foo = 100;
$foo = $foo + 1;

In this way you declare the varible first, and then you reuse it later on and update it.

What's the sense?

Let's say that you have a for cycle for example, that runs a certain amount of time, and you want to update the value of $foo each time that a particular condition appends, you can have something like that (pseudocode):

<?php
$foo = 5; //for some reason we need to start from 5, doesn't matter why
for([FOR CONDITION HERE]){
  if([SOMETHING IS TRUE]){
    //Some other useful code
    $foo++; //This will add 1 to $foo, same as $foo = $foo + 1;
  }
}
echo $foo; //We will see how many times the conditional statement has been true. For i.e. if the result is 8, it means that it was true 3 times