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

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.