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 trialcsj
12,678 Points[PHP Basics] Can't pass code challange
I don't understand why it wont pass. I'm sure it's inefficient, messy and could be better written. But.
Bummer! Use the variables to display the message
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;
$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;
//Place your code below this comment
$GPA = "has a GPA of";
$HonorRole = "made the Honor Role";
if ($studentOneGPA === 4.0) {
echo "$studentOneName $HonorRole";
} else {
echo "$studentOneName $GPA $studentOneGPA";
}
if ($studentTwoGPA === 4.0) {
echo "$studentTwoName $HonorRole";
} else {
echo "$studentTwoName $GPA $studentTwoGPA";
}
?>
Darrell Conklin
Python Development Techdegree Student 22,377 PointsPeople have been asking about this test all day long since it came out the other day
csj
12,678 PointsThanks Darrell, I have taking the custom variables out and thrown in "NAME made the Honor Role" and "NAME has a GPA of GPA". But it is still failing. I've never had troubles understanding the questions, but this is confusing. I'm moving on.
3 Answers
Darrell Conklin
Python Development Techdegree Student 22,377 PointsIf you copy paste the code below I can guarantee you will pass. It also didn't like the identical operator it wanted the equality one. A little buggy if you ask me.
if ($studentOneGPA == 4.0) {
echo "$studentOneName made the Honor Role";
} else {
echo "$studentOneName has a GPA of $studentOneGPA";
}
if ($studentTwoGPA == 4.0) {
echo "$studentTwoName made the Honor Role";
} else {
echo "$studentTwoName has a GPA of $studentTwoGPA";
}
Darrell Conklin
Python Development Techdegree Student 22,377 PointsIt would be nice if it were more specific about the actual problem preventing your from passing.
Eric Jones
24,588 PointsBe sure to use the appropriate spelling of Honor Roll
Chris Adamson
132,143 PointsIt looks like your attempting shell (bash) string interpolation. Normally, you could make your code work using the . (dot) concatenation operator. For this exercise, it doesn't need extra variables as you declared.
if ($studentOneGPA == 4.0) {
echo $studentOneName . " made the Honor Role";
} else {
echo $studentOneName . " has a GPA of " . $studentOneGPA;
}
if ($studentTwoGPA == 4.0) {
echo $studentTwoName . " made the Honor Role";
} else {
echo $studentTwoName . " has a GPA of " . $studentTwoGPA;
}
csj
12,678 PointsThanks guys.
Darrell Conklin
Python Development Techdegree Student 22,377 PointsDarrell Conklin
Python Development Techdegree Student 22,377 Pointstake out your custom variables and only use the one's they provided this test is extra picky about the way it's written