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 trialShilpa Kothari
4,518 PointsHelp
No idea what is wrong. Please help
<?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
Kristian Terziev
28,449 PointsLeave the "a palprime" message out of the if/else scope. It should look like this:
if ($checker->isPalprime()) {
echo "is";
}
else {
echo "is not";
}
masterpowers
3,061 Points<?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.";
?>
masterpowers
3,061 PointsThis 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.";
?>
masterpowers
3,061 PointsUse the Code i Post Above it will Work, You just need to put the Propert $checker->number Inside the Object Method isPalprime.
Kristian Terziev
28,449 PointsAt 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
4,518 PointsI 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
4,518 PointsPlease help me. I need response to correct my code.
Shilpa Kothari
4,518 PointsShilpa Kothari
4,518 PointsHi Kristian, You are the best. Thank you.
Kristian Terziev
28,449 PointsKristian Terziev
28,449 PointsGlad to know I helped :) Keep going!