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 Basic PHP Website (2018) Adding a Basic Form Objects

Robbie Thomas
Robbie Thomas
31,093 Points

Adding A Basic Form: Objects / Challenge 3 of 4

Here is the code:

<?php

include("class.palprimechecker.php");

$checker = new PalprimeChecker;

$number->$checker = 17 // trouble with this line


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

?>

Having troubles with $number->$checker = 17, any help would do.

palprimes.php
<?php






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

?>

2 Answers

Hi Robert,

You have the object and property reversed on that line. When using the arrow operator, you have the object on the left and the property or method you're trying to access on the right. $number doesn't need a dollar sign either because you already have one on $checker to indicate it's a variable. And you have to end the line with a semicolon.

$checker->number = 17;

The other issue is with the echo statement. You have to access the number property through the checker object and the challenge mentions that you should preserve the space after the number.

echo "The number " . $checker->number . " ";
Pai Boony
PLUS
Pai Boony
Courses Plus Student 4,529 Points

thanks Robert for the question, I had the same problem. And also thanks to Jason I can solve my problem coz your answer.