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

Lydia King
Lydia King
1,188 Points

Problem in PHP Basics Challenge

Please help me find the error in the 3 step challenge at the of this module.

I create the following variables:

<?php

$integerOne = 1; $integerTwo = 2; ?>

The grader says this is correct.

Then for challenge step 2, I enter:

<?php var_dump( $integerOne + 5 ); var_dump( $integerTwo - 1 ); ?>

Then I get the following error message:

"Oops! It looks like Task 1 is no longer passing."

The grader recommends that I should go back to step 1. What can I fix in step 1 if my answers are correct?

Can you tell me how to resolve this? Thanks in advance.

index.php
<?php
var_dump( $integerOne + 5 );
var_dump( $integerTwo - 1 );
?>

4 Answers

Algirdas Lalys
Algirdas Lalys
9,389 Points

Hi Lydia King,

I noticed that you are using var_dump( $integerOne + 5 ); . var_dump() function is really great for testing, but you don't need it for this challenge. And when you are writing $integerOne + 5 you are adding 5 to $integerOne, but not storing that value. Task 2 asks to Add 5 to $integerOne. Subtract 1 from $integerTwo. There are two ways how you can add some value to the existing variable 1) $integerOne += 1; 2) $integerOne = $inetegerOne + 1; Pick one which is most comfortable for you.

Sometimes challenges require that you leave your original code from part 1 like this challange does. So basicly for this challenge you have to write more code in each task. so for example first task asked to create two integer variables. So it would be something like this.

<?php
// Place your code below this comment
// First part of challenge
$integerOne = 1;
$integerTwo = 2;
?>

For the second task it asks to Add 5 to $integerOne. Subtract 1 from $integerTwo It could be achieved in different ways. For example.

<?php
// Place your code below this comment
// First task of challenge
$integerOne = 1;
$integerTwo = 2;

// Second task of challenge
// Add five to integer one variable
$integerOne += 5;
// Subtrack 1 from integer two variable
// just one line missing for task 2:)
?>

I hope it will help you to move on.

Lydia King
Lydia King
1,188 Points

Hi Algirdas,

Thanks for your response. I think there might be something wrong with the interface because I'm still getting the error message after trying your solution.

"Oops! It looks like Task 1 is no longer passing."

Note, I have tried our your solution in interactive PHP on in my own terminal and it works fine.

Jordan Hausman
Jordan Hausman
5,275 Points

Hello, I'm not sure what you tried after the first persons response. Heres how I would solve a similar problem: add y to variableX

<?php
    $variableX = x;
    $variableX = $variableX + y;
    // so now variableX = x+y
?>
Algirdas Lalys
Algirdas Lalys
9,389 Points

Ok, I will try to go through this challenge step by step. 1 Task asks us to: 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

<?php

//Place your code below this comment
// Creating $integerOne with value 1
$integerOne = 1;
// Creating $integerTwo with value 2
$integerTwo = 2;
?>

2 Task asks us to: Add 5 to $integerOne. Subtract 1 from $integerTwo.

<?php

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

// Adding 5 to $integerOne 
$integerOne += 5;
// Subtracting 1 from $integerTwo
$integerTwo -= 1;
?>

3 Task asks us to: Create a New Float Variable named $floatOne with a value of 1.5. Without changing the value of $integerOne or $floatOne, multiply $integerOne by $floatOne and display the results.

<?php

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

// Adding 5 to $integerOne 
$integerOne += 5;
// Subtracting 1 from $integerTwo
$integerTwo -= 1;

// Creating $floatOne with value 1.5
$floatOne = 1.5;
// Showing / Displaying $integerOne multiplied by $floatOne
echo $integerOne * $floatOne;
?>