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


Joseph Burdick
Joseph Burdick
11,543 Points

Can NOT get passed using a third-party library in PHP

In build-a-simple-php-application/wrapping-up-the-project/objects I cannot get past the quiz. Here's my code:


$number = 17; $checker = new PalprimeChecker();

//$value = $checker->number($value); //if //if (!$checker->$number) echo $checker->number(17); echo "The number ". $number . " "; echo "(is|is not)"; echo " a palprime.";


Nothing seems to work. I've watched the video many times and I see that $mail->ValidateAddress($email) works but why isn't my code working?

2 Answers

Sean T. Unwin
Sean T. Unwin
28,690 Points

You have a few things going on here as to why it's not working.

First, I think the variables you are setting are confusing you. Take a step back and think about if you really need all those variables declared.

You set a $number variable, but then you create a $value variable and attempt to set it to $checker->number with a value of itself. Another issue with this is $checker-number is a property, not a method so you don't set it within parenthesis. Using your $number variable we would set it via $checker->number = $number;. This could be a little confusing, as well, because you're using a variable name as the same as the property. It's not wrong, but you have be aware to be able to distinguish the two.

Following that you have two if statements. It seems like one is nested inside the other, but there are no curly brackets. You only need one if statement. While checking to see if $checker->number exists is good practice, it should probably be done with the isset() method, but that's an aside to our current dilemma and is not required here.

You need to use the $checker->isPalprime() method within an if statement and if true echo "is" and if false (using else) echo "is not".

I hope that helps. :)