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

Sechaba Motaung
Sechaba Motaung
1,602 Points

Hi I am not quite sure what i am doing wrong here, i have tried correcting my result a few times. Please help

logic , students GPA

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 Honour Roll";
} else { echo "$studentOneName has a GPA of $studentOneGPA";}

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

2 Answers

Antonio De Rose
Antonio De Rose
20,885 Points
<?php
//first I would ask you to indent the code properly, to increase readability
//you have to understand, how you mix variables with strings - you have done it wrong
//when combining, you gotta use the concatenation or dot operator 
//Place your code below this comment
//variables need not have to be surrounded with quotes
//last spelling mistakes, you gotta do just as per to the question, not to over do it
if ($studentOneGPA == 4.0 ){
    echo $studentOneName." made the Honor Roll";
} else { 
   echo $studentOneName." has a GPA of ".$studentOneGPA;
}

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

If you put the variable name inside double quotes it will evaluate the variable and concatenate it, which makes it much more readable.

"$studentTwoName made the Honor Roll" will work.

You have to get the language of the output exactly right:

NAME made the Honor Roll.

You say "NAME has made the Honour Roll" in the first case and "NAME has mase the Honour Roll"

you have an extra "has" in each case and you have misspelled "made" in the second case.