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

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.