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

How to assign a value17 to the property number of the object $checker and what condition should i put for echo is|is not

This is the problem statement PalprimeChecker objects have a property called number. This task has two parts. 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. (Be sure to preserve the space after the two hash signs by concatenating a space after the number.)


$checker = new PalprimeChecker();
echo "The number" . " $checker->number()";
echo "(is|is not)";
echo " a palprime.";


3 Answers

Hello! Your are doing great so far!

The only problem I see so far in this challenger is that you are treating the 'number' property like a method.

Methods are like functions in that they require those parenthesis you have there after 'number'. Number in this objects's case is not a method.

set properties like so:

$object = new Object();
$object->property = 'foo'; 

further, if your going to concatenate the value of number, it should not be in quotes.

Thnx for ur help

$checker = new PalprimeChecker();

$checker->number = 17;

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

           Would some mind taking a look. I don't get why this doesn't work. It is most probably something stupid

The error i get is the following

PHP Catchable fatal error: Object of class PalprimeChecker could not be converted to string in palprimes.php on line 9

But im not sure whats happening