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

Andre Heath
PLUS
Andre Heath
Courses Plus Student 1,059 Points

What am i doing wrong in comparing these?

<?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 $studentOneGPA of 4.0"; }

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

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 $studentOneGPA of 4.0";
     }

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

2 Answers

Try changing "$studentOneName has a $studentOneGPA of 4.0" and "$studentTwoName has a $studentTwoGPA of 4.0" to "$studentOneName has a GPA of $studentOneGPA" and "$studentTwoName has a GPA of $studentTwoGPA".

Good Luck, Alex

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

Hi there! Would it be comforting to know that there's nothing wrong with your comparisons? It's the strings that you're echoing out that are incorrect.

Read carefully the instructions about how the strings are to be formatted. These must match exactly. Here's a few hints:

  • you've written "has made" where they want just "made"
  • The honor roll message only prints out when the GPA is 4.0 thus, if the honor roll message hasn't printed out the GPA wasn't 4.0, it was something else
  • In the first scenario it should print out "Dave has a GPA of 3.8"
  • Check the preview to see what is being printed out

Hope these hints help! :sparkles: