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 trialAbdülhak Gözegir
4,689 PointsI couldn't run isPalprime method in the challenge.
I spent one hour and looked php documents many times. I've tried various ways of if conditional. It didn't work.
I think maybe I misunderstood some aspects of the descriptions because my english isn't very well.
here is description of 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”.
////
here is my code
<?php
include("class.palprimechecker.php");
$checker = new PalprimeChecker();
$checker->number = 17;
echo "The number " .$checker->number." ";
if ($checher->isPalprime()) {
echo "is";
}
else {
echo "is not";
}
echo " a palprime.";
?>` ` `
1 Answer
Logan R
22,989 PointsAfter attempting your code, I have found your very simple error.
if ($checher->isPalprime()) {
echo "is";
}
else {
echo "is not";
}
You have $checher
instead of $checker
. Change that 1 character and your code will now work :)
Best of luck!
Abdülhak Gözegir
4,689 PointsAbdülhak Gözegir
4,689 PointsThanks
I don't know how could I stuck although checked it many times.
Logan R
22,989 PointsLogan R
22,989 PointsIt's all good :) I have moments like these when I programming too. It's easy to do and hard to catch sometimes!