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

PHP Basics -Daily Exercise Program - Conditionals

Any Idea?

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

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

//Place your code below this comment
$GPA = 4.0;
if($studentOneGPA === $GPA)
  echo "$stundentOneName made the Honor Roll\n";
else
  echo "$studentOneName has a $studentOneGPA of  $GPA\n";

if($studentTwoGPA === $GPA)
  echo "$studentTwoName made the Honor Roll\n";
else
  echo "$studentTwoName has a $studentTwoGPA of $GPA\n";


?>

2 Answers

You forgot about using { and }!

Try this:

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

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

//Place your code below this comment
$GPA = 4.0;
if($studentOneGPA === $GPA) {
  echo "$stundentOneName made the Honor Roll\n";
} else {
  echo "$studentOneName has a $studentOneGPA of  $GPA\n";
}

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

Good luck! ~alex

Alex Thank you for the answer! The problem is the same! "Bummer! You need to check that $studentOneGPA is equal to 4.0"

Oh think this is because the code challenge is picky and looked at the condition and thought it would be $studentOneGPA == 4.0 but it wasn't.

Try getting rid of the GPA variable and replacing all existence of it with the value 4.0 like this:

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

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

//Place your code below this comment
if($studentOneGPA === 4.0) {
  echo "$stundentOneName made the Honor Roll\n";
} else {
  echo "$studentOneName has a $studentOneGPA of  $GPA\n";
}

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

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

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

//Place your code below this comment if($studentOneGPA === 4.0) { echo "$stundentOneName made the Honor Roll\n"; } else { echo "$studentOneName has a $studentOneGPA of 4.0 \n "; }

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

"Bummer! Use the variables to display the message"

Alex thanks again! I can't find any solution!