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

janapozelaite
janapozelaite
9,245 Points

Challange solving

Could you please suggest what's wrong with my code, since in preview it shows needed result but still it does not let to pass the challenge and writes " Use the variables to display...".

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 Role';

} else {
echo " $studentOneName has a GPA of GPA";

}


if ( $studentTwoGPA === 4.0 ) {
echo " $studentTwoName made the Honor Role";

} else {
echo " $studentTwoName has a GPA of GPA";

}


?>

3 Answers

Shane Oliver
Shane Oliver
19,977 Points

You are adding your variables as part of the string. You need need to concatenate the variables and the strings.

$name = 'bob';
echo $name . ' thinks fullstops to concatenate variables is pretty odd.';
Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Shane Oliver is correct in one instance. On this line you have it in single quotes so it won't expand the variable to show the value. However, there are other issues here. And some of them are in your strings that are being echoed out, but there's also a bug with this challenge that I reported on Friday. You may not use the identical operator or === and make it pass.

In the strings that you're having problems with, you have written this for example:

echo " $studentTwoName has a GPA of GPA";

but what we want is:

echo "$studentTwoName has a GPA of $studentTwoGPA";

You can see a solution that I posted here that will show you exactly how I did it to get around the bugs (for the time being). Hope this helps! :sparkles:

janapozelaite
janapozelaite
9,245 Points

Thank you so much guys :)