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

Shilpa Kothari
Shilpa Kothari
4,518 Points

Help

No idea what is wrong. Please help

palprimes.php
<?php include 'class.palprimechecker.php';

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


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

6 Answers

Leave the "a palprime" message out of the if/else scope. It should look like this:

if ($checker->isPalprime()) {
  echo "is";
}
else {
  echo "is not";
}
Shilpa Kothari
Shilpa Kothari
4,518 Points

Hi Kristian, You are the best. Thank you.

Glad to know I helped :) Keep going!

<?php
include("class.palprimechecker.php");
$checker = new PalprimeChecker;
$checker->number = 17;





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

?>

This is how i do it

<?php include("class.palprimechecker.php"); $checker = new PalprimeChecker; $checker->number = 17;

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

?>

Use the Code i Post Above it will Work, You just need to put the Propert $checker->number Inside the Object Method isPalprime.

At which step of the challenge are you stuck? What error do you get?

By the way you're missing the closing curly bracket. Try adding it and see if that works

Shilpa Kothari
Shilpa Kothari
4,518 Points

I added () in the end of this $checker = new PalprimeChecker(); where do you want me to add curly brackets. Challenge Task 5 of 7

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”.

bummer (It seems like you are calling the right method and you have the removed various placeholder characters (##|()), but something in the output is not quite right. Please double-check the preview.)

in preview I am getting (The number 17 is not Palprime) which is correct.

Shilpa Kothari
Shilpa Kothari
4,518 Points

Please help me. I need response to correct my code.