Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics Unit Converter Manipulating Numbers

Miguel Nunez
Miguel Nunez
3,266 Points

Add 5 to $integerOne. Subtract 1 from $integerTwo.

//Place your code below this comment $integerOne = 1; $integerTwo = 2;

5 Answers

Daniel Gauthier
Daniel Gauthier
14,999 Points

Hey Miguel,

The challenge is looking for the following code:

<?php

//Place your code below this comment
$integerOne = 1;
$integerTwo = 2;

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

The challenge basically wants to see you use those += and -= operators, while also showing you know the difference between initializing a variable (first step) and manipulating them (second step).

Good luck with the course!

Daron Anderson
Daron Anderson
2,566 Points

Thank You Daniel For the answer it helped, and thank n.you Miguel for asking the question!

The Longer way xD

<?php

//Place your code below this comment
$integerOne=1;
$integerTwo=2;
$floatOne=1.5;

$integerOne=($integerOne + 5);
$integerTwo=($integerTwo - 1);
?>

Took me some time to understand, but also found out this post. never thought of using the += or -= operators and also the question was bit confusing, but somehow this worked, thereafter i just wanted to see if there was any other answer, thanks to this post i found a shorter way to complete the same question.

Adios Daniel Gauthier thanks man..thanks alot xD

Enea Jorgji
Enea Jorgji
6,038 Points

I was trying the short way, but it took me some time to understand xD

For more context this is part of the Assignment Operators http://php.net/manual/en/language.operators.assignment.php

Greg Sargent
Greg Sargent
3,812 Points

Wow I would never have thought to use those operators. Thanks for sharing!

Thank you! I wouldn't have figured out to use those operators either