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 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.