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 PHP Basics Daily Exercise Program Conditionals

Martin Park
Martin Park
12,792 Points

Help with Students GPA Challenge?

Hi,

I can't seem to pass this PHP challenge. I'm sure I'm doing something wrong but I can't see it? Anyone able to help please?

index.php
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment

if ($studentOneGPA == 4.0) {
  echo "$studentOneName has made the Honor Roll";
} else {
  echo "$studentOneName has a GPA of $studentOneGPA";
}


if ($studentTwoGPA == 4.0) {
  echo "$studentTwoName has made the Honor Roll";
} else {
  echo "$studentTwoName has a GPA of $studentTwoGPA";
}


?>

1 Answer

You have an extra word in your echo statement, aside from that 100% valid.

echo "$studentOneName has made the Honor Roll";

should be:

echo "$studentOneName made the Honor Roll";
Martin Park
Martin Park
12,792 Points

Oh my gosh! I'm so embarrassed! Thank you, was staring at that for ages. That'll teach me not to read things properly.

I can't tell you how many hours I have spent looking at errors in my code where I typed one thing and subconsciously inserted something extra. Seems silly but the trick is to read everything out loud including punctuation e.g "Echo double-quote dollar sign student one name has made the honor roll double-quote semicolon".

Semicolons are important because the error it produces won't be for the line that is missing it.

Martin Park
Martin Park
12,792 Points

Thanks for the suggestion Corey. I'll certainly try that reading out loud tip :)