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 trialSajid Latif
Full Stack JavaScript Techdegree Student 22,368 PointsHelp needed
Im not strong at the object orientet questions.. please help :smile
<?php
require_once("class.palprimechecker.php");
$checker = new PalprimeChecker();
$checker->number = 16661;
echo "The number ". $checker->number;
if ($checker->isPalprime(number)) {
echo "is a palprime.";
exit;
}else
echo "is not a palprime.";
?>
5 Answers
Sajid Latif
Full Stack JavaScript Techdegree Student 22,368 PointsIve tried with this, but not working... hmm.. strange
<?php
require_once("class.palprimechecker.php");
$checker = new PalprimeChecker();
$checker->number = 16661;
echo "The number ". $checker->number;
if ($checker->isPalprime()) {
echo "is a palprime.";
exit;
}
} else {
echo "is not a palprime.";
}
?>
thomascawthorn
22,986 PointsIt looks like you're missing some brackets for starters:
if ($checker->isPalprime(number)) {
echo "is a palprime.";
exit;
} else {
echo "is not a palprime.";
}
Make sure you add the curly braces around the else block :-)
What's the question?
Sajid Latif
Full Stack JavaScript Techdegree Student 22,368 PointsThanks for your help :)
Now I added the curly braces. But the number 16661 is giving me a headeach. It was before 17 but I have to change it to 16661.
What do you think: is 16661 a palprime? Assign the number property of $checker a value of 16661. Be sure to refresh the preview before you finish this step to find out.
thomascawthorn
22,986 PointsHave you refreshed the preview screen? Also, is it giving you an error message back?
Sajid Latif
Full Stack JavaScript Techdegree Student 22,368 PointsYes. It is giving me this BUMMER:
Bummer! Please change the number property. We checked the number 17 last task; we're moving on to numbers with at least three digits. :)
thomascawthorn
22,986 PointsAh, I imagine this is giving you a syntax error:
<?php
if ($checker->isPalprime(number)) {
because number is not a valid variable. In fact, does 'isPalprime' need an argument?
You're storing the value inside the checker with
<?php
$checker->number = 16661;
Sajid Latif
Full Stack JavaScript Techdegree Student 22,368 PointsBut I cannot figure out whats the issue is here? :)
thomascawthorn
22,986 Points<?php
if ($checker->isPalprime(number)) {
should be
<?php
if ($checker->isPalprime($checker->number)) {
BUT, your $checker already has the $checker->number 'saved' inside of it.
You shouldn't have to do this:
<?php
if ($checker->isPalprime($checker->number)) {
at all.
Try not sending in an argument (remove number):
<?php
if ($checker->isPalprime()) {
or updating as above.
thomascawthorn
22,986 Pointsthomascawthorn
22,986 PointsI've gone through the task.
Stage 5/7 :
So you don't need to send anything into the method.
This is the completed code:
I imagine your random 'exit;' was throwing it off! Your code would've acheived the correct outcome, but the challenge didn't like it.