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 trialMelinda Caldwell
498 PointsWhat am I doing wrong?
I am trying to figure out what is wrong with my code.
<?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 Roll.'; } else { echo '$studentOneName has a GPA of GPA';
} ?>
<?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 Roll.';
} else {
echo '$studentOneName has a GPA of GPA';
}
?>
Eric Butler
33,512 PointsYep, Phil's answer is right! And ditto what Alexander said.
Melinda Caldwell
498 PointsThank you for helping me. I don't understand why I am still getting an error though. It says "Bummer! You need to check that $studentOneGPA is equal to 4.0"
1 Answer
Phil Baker
27,352 PointsIt's the single quotes on lines 11 and 13 preventing the variable values from being printed to screen. In order to fix it you can either use double quotes or single quotes with string concatenation. e.g.
Single quotes with string concatenation
<?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 Roll.';
} else {
echo $studentOneName . ' has a GPA of ' . $studentOneGPA;
}
?>
Double quotes
<?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 Roll.";
} else {
echo "$studentOneName has a GPA of $studentOneGPA";
}
?>
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsCan you make your comment into an answer so people can give you upvotes and best answers? It actually gives you bonus points (if you get upvotes/best answers).