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

Task Completed without imputing the right answer

Hey Teamtreehouse,

I was in the middle of a task for a challenge : Wrapping up the project > Objects > task 4/7

The question or task at hand was the following:

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

Now, the problem is not that i am stuck, i simply finished the first part of the question, clicked submit, (expecting a fail and hint to see if i was on the right track)and instead passed the task without even having to complete the second part of the challenge.

I just wanted to bring this to your attention, first since i was having issues with the task(but i'm pretty sure i figured the hardest part out) and am not sure if i was right with my answer. Most importantly i'm sure you guys don't want any bugs in the product.

i cant post an image(you guys should seriously add an image upload to the forum)but, i did take a screen capture of the issue if you would like to see what i'm seeing.

thanks

7 Answers

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

That should work, so I suspect you are missing something. What's the error? If you don't get a helpful error message, then you probably have some invalid PHP code (like a missing semicolon at the end of a line).

Here's the code I have that passes the task 3:

<?php

    require_once("class.palprimechecker.php");
    $checker = new PalprimeChecker();

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

?>
Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

You have this line of code:

$checker-> "number" = 17;

Because number is the name of a property, you don't actually put it in quotation marks. (A property is like a variable that way; it's a variable inside of an object.) That line should look like this:

$checker->number = 17;

Does that help?

That's interesting. I believe in a few of the very first challenges of Website Basics (create an h1, for example), I didn't need to use the < /h1 > tag to close the h1 tag. Also, in another challenge (can't remember which), a challenge could be completed without inserting the " ; " symbol in the .css file.

Randy Hoyt
STAFF
Randy Hoyt
Treehouse Guest Teacher

Hey Justin,

Thanks for finding this. I was checking to make sure the hash signs (#) were removed, but I wasn't checking that they were replaced with the number! I have added the additional check and re-deployed the code challenge. (You had to add it in eventually before passing the whole code challenge, but it now checks at the correct step. :~)

Thanks again!

Hey Randy,

Thanks for the fix, unfortunately i am now having an issue with an earlier task that i was completing yesterday before the issue you fixed.

i am now on task 3/7

for this task you need to add a variable named $checker and assign that variable an object called new palprimechecker

seems simple enough from what i recall, all i needed to do was the following, the task prior to this i added the require_once function

then :

$checker = new palprimechecker();

the task is not passing, and i went to check back to my tutorial and previous work to see that this is what i imputed before with success, now to just see it not pass.

any suggestions ? am i just being careless and missing something ? i am pretty sure this passed for me yesterday although im open to any solution.

thanks

Hey Randy! i am now on task 4/7

that´s my code:

<?php

require_once ("class.palprimechecker.php"); $checker = new PalprimeChecker(); $checker-> "number" = 17;

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

?> not work... :( help me

THIS GOT ME PAST THAT STEP

$checker -> number = 17;

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

but the first "echo" isn't logical because the number 17 is a string that I wrote... not the "property number" that is computer through the PalprimeChecker() object.

Randy Hoyt
Randy Hoyt
Treehouse Guest Teacher

Good catch! Thanks for reporting it. I'll see what I can do to address it.

Just FYI: On step 4/7, I just tried "The number 17" instead of concatenating and it still allows a success.