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

Completely Lost!!

Hi, been trying to get to the bottom of this code challenge for a while now, in and out of of other course's. I've re watched the vid a couple a times wrote notes and still can't get to the bottom of it ! managed to squeeze my knowledge to task 5 but that's the end of the road .....

Help would be very much appreciated so I can carry on with the course ...

Thanks Craig

Tommy Gebru
Tommy Gebru
30,164 Points

Hey Craig,

Can you post your code? Thx

Hi Tommy,

Question is :

PalprimeChecker objects have a method called isPalprime(). This method does not receive any arguments. It returns true if the number property contains a palprime, and it returns false if the number property does not contain a palprime. (Tip: 17 is not a palprime.) Turn the second echo statement into a conditional that displays β€œis” or β€œis not” appropriately. The conditional should call the isPalprime method of the $checker object. If the isPalprime method returns true, then echo β€œis”; otherwise, echo β€œis not”.

My code so far

<?php

require_once ('class.palprimechecker.php');
$checker = new PalprimeChecker();
$checker->number = 17;



echo "The number" . $checker->number . " ";
echo "(is|is not)";
echo " a palprime.";

?>

I've tried everything I knew but no joy I know its a "if" statement and echoing out is not the problem its between the () I have the issue...

Thanks

2 Answers

Tommy Gebru
Tommy Gebru
30,164 Points

Code challenge 5

<?php

include('class.palprimechecker.php');

$checker = new PalprimeChecker;
$checker->number = 17;

echo "The number ".$checker->number; 
if ($checker->isPalprime()) { 
  echo "is"; 
} else { 
  echo "is not"; 
}                     

echo " a palprime.";

?>

Hey Craig,

Your condition should look like this:

if ($checher->isPalprime())

or more complete:

if ($checher->isPalprime()) {
    echo "is";
}
else {
    echo "is not";
}