Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Wrapping Up The Project Objects

Andrew Norris
Andrew Norris
4,857 Points

Build a Simple PHP Application I'm stuck on the Objects Code Challenge Task 4 of 7. Can't come up with correct syntax

Not sure if not correctly assigning a value of 17 to the number property of the $checker object, or the echo statement that display it.

palprimes.php
<?php
include('class.palprimechecker.php');

$checker = new PalprimeChecker();
$number = 17;
$checker->number($number);


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

?>

1 Answer

Hi Andrew,

number is a property and not a method. So you need to assign the number 17 to that property. You can't call it like a function and pass in the number as an argument. $checker->number = 17;

Also, the challenge is instructing you to preserve the space after the number in the echo statement. You'll need to concatenate a string with a single space onto the end.

echo "The number " . $checker->number . " ";

Andrew Norris
Andrew Norris
4,857 Points

Thanks, Jason. That works. I understand now. During my many attempts at these two lines of code, I alternated between having one syntactically correct and the one wrong.