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

Byron Farrell
Byron Farrell
5,700 Points

PHP basics challenge task keeps telling me my code is wrong?

Hi, I am currently doing the PHP basics course. I have started the challenge task but the website keeps telling me that I am missing an else block even though I have one. I am probably not seeing something. Can anyone see what is wrong with this code?

Thanks for your time!

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 made the Honor Roll";
}// END if
else {
  echo "$studentOneName has a GPA of $studentOneGPA";
}// END else


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

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! The great news is that your code is just fine. The checker however, really does not like your comments. If I simply remove the END if and END else comments, your code passes with flying colors! Please note that these are perfectly valid comment styles in PHP.

I think maybe we should tag Alena Holligan and see if she can adjust the checker to either allow comments or make a note in the instructions regarding them.

Hope this helps! :sparkles:

Byron Farrell
Byron Farrell
5,700 Points

Thanks Jenifer! I removed the comments and it worked perfectly.

Alena Holligan
Alena Holligan
Treehouse Teacher

Thanks for tagging me Jennifer Nordell , I updated the challenge to ignore the comments