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

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,950 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 :)