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.
Andrew Norris4,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.
<?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."; ?>
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 . " ";