Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP PHP Basics Daily Exercise Program Conditionals

Having trouble with PHP code challenge: Boolean Operations.

I ran the code below and it displays the desired results; however, I am not able to pass the code challenge. The error I keep getting is: You need to check StudentOneGPA is EQUAL to 4.0.

I feel like that's what I've executed but I may be missing something simple or have formatted my code incorrectly. Maybe the first part of the question has something to do with it? "Check if each student has a 4.0 GPA"?

Appreciate the help/input in advance.

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

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

//Place your code below this comment

IF ($studentOneGPA == "4.0") { //If student has a a GPA of 4.0
  ECHO "$studentOneName made the Honor Roll"; //Then add to Honor Roll
} ELSE {
  ECHO "$studentOneName has a GPA of $studentOneGPA"; //If not, then display actual GPA
}

IF ($studentTwoGPA == "4.0") {
  ECHO "$studentTwoName made the Honor Roll";
} ELSE {
  ECHO "$studentTwoName has a GPA of $studentTwoGPA";
}
?>

2 Answers

Rob Crossland
Rob Crossland
9,158 Points

4.0 isn't a string its a number so quote marks are not needed.

In your example you're checking whether $studentOneGPA is equal to string '4.0' where it should be is equal to 4.0

Hope this helps x

I had tried this before, but I have a strong feeling that I just need to lowercase my keywords and do this. Thanks so much.

Hi Abdul,

You're checking if the gpa's are equal to the string "4.0". You should check if they are equal to the number 4.0

Also, even though keywords in PHP are not case sensitive, the challenge is requiring that if and else be in lower case.

It's also a good habit to get into to make all your keywords lowercase because that's what you will commonly see.

I have bad SQL habits. lol Alright onwards and forward!