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 Build a Simple PHP Application Wrapping Up The Project Objects

Neslee Rodillo
Neslee Rodillo
19,615 Points

I don't understand what is being asked in task 6

I don't understand how I can pass this stage without removing the hard coded number in the out put.

Every time, I remove the number '17' in the output, it then says the previous stage is not passing

Challenge task 6 of 7 What do you think: is 16661 a palprime? Assign the number property of $checker a value of 16661. Be sure to refresh the preview before you finish this step to find out.

My answer:

<?php


include "class.palprimechecker.php";

$checker = new PalprimeChecker ();
$checker -> number = 16661  ;

echo "The number " . $checker->number . " ";

if  (!$checker->isPalprime()) {

  echo "is not"; 

} else {

  echo "is";
}


echo " a palprime.";

?>

Error: Oops! It looks like Task 4 is no longer passing. (which is about using '17' instead of '16661')

2 Answers

Paul Johnson
Paul Johnson
18,924 Points

In one of the earlier stages you are told to concatenate the number onto the first string, so 17 shouldn't be hard coded anyway.

echo "The number " . $checker->number . " ";

Try changing that and see if it helps. You should then be able to change the $checker->number variable to 16661 and it should pass.

Your if statement could use a little work to, $checker->isPalPrime returns true or false, so !==FALSE is not needed. You should be using an if/else statement

if(condition) {
    //Do something
} else {
    //Do something else 
}
Neslee Rodillo
Neslee Rodillo
19,615 Points

fixed :D and completed the challenge.... Sweet!!!!!!!!