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

General Discussion

Stuck on PHP Objects Challenge

First, assign that property a value of 17. Second, remove the two hash signs (##) in the first echo statement and instead concatenate the value of this number property.

Stuck on this assignment. Challenge 4 of 7

Anyone under this assignment??

include ('class.palprimechecker.php');

$checker = new palprimechecker();

echo "The number ##";
echo "(is|is not)";
echo " a palprime.";

?>

6 Answers

for the second part...i thought the answer was echo "The number " . $checker;

was correct but I cannot figure out the first part so I am unsure of the second as well.

Mike Costa
PLUS
Mike Costa
Courses Plus Student 26,362 Points

Hey Justin,

In order to access an objects property, you'll need to use the arrow operator.

$checker->number;

Hope this helps.

Still can't seem to figure it out...

so far i have this

include ('class.palprimechecker.php');

$checker = new palprimechecker(); $checker->number;

echo "The number " . $checker; echo "(is|is not)"; echo " a palprime.";

Sorry this should be easier to read include ('class.palprimechecker.php');

$checker = new palprimechecker();
$checker->number;

echo "The number " . $checker;
echo "(is|is not)";
echo " a palprime.";
Mike Costa
PLUS
Mike Costa
Courses Plus Student 26,362 Points

Now that you have access to that property, you'll need to assign it a value. As an example:

$obj->property = value;

this will work

<?php

include_once('class.palprimechecker.php');
$checker = new PalprimeChecker();

$checker->number = 12421;

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

?>