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 trialSudip Banerjee
Courses Plus Student 3,593 PointsHow to assign a value17 to the property number of the object $checker and what condition should i put for echo is|is not
This is the problem statement PalprimeChecker objects have a property called number. This task has two parts. First, assign that property a value of 17. Second, remove the two hash signs (##) in the first echo statement and instead concatenate the value of this number property. (Be sure to preserve the space after the two hash signs by concatenating a space after the number.)
<?php
require_once("class.palprimechecker.php");
$checker = new PalprimeChecker();
$checker->number()=17;
echo "The number" . " $checker->number()";
echo "(is|is not)";
echo " a palprime.";
?>
3 Answers
Leonardo Hernandez
13,798 PointsHello! Your are doing great so far!
The only problem I see so far in this challenger is that you are treating the 'number' property like a method.
Methods are like functions in that they require those parenthesis you have there after 'number'. Number in this objects's case is not a method.
set properties like so:
<?php
$object = new Object();
$object->property = 'foo';
?>
further, if your going to concatenate the value of number, it should not be in quotes.
Ben Hudson
2,307 Points <p>
$checker = new PalprimeChecker();
$checker->number = 17;
echo "The number" . $checker . " ";
echo "(is|is not)";
echo " a palprime.";
?></p>
```
Would some mind taking a look. I don't get why this doesn't work. It is most probably something stupid
Ben Hudson
2,307 PointsThe error i get is the following
PHP Catchable fatal error: Object of class PalprimeChecker could not be converted to string in palprimes.php on line 9
But im not sure whats happening
Sudip Banerjee
Courses Plus Student 3,593 PointsSudip Banerjee
Courses Plus Student 3,593 PointsThnx for ur help