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

If else

Hi I really need help! I have trouble in understanding this assignment so my code is very weird. But can someone please help me and explain what I am meant to do here

This is my code: <?php $studentOneName = 'Dave'; $studentOneGPA = 3.8;

$studentTwoName = 'Treasure'; $studentTwoGPA = 4.0;

//Place your code below this comment if ($studentOneName > 4.0) { echo 'Dave has a GPA of 4.0';

} elseif ($studentTwoName < 3.8) { echo 'Treasure has a GPA of 3.8'; {

} else { echo 'Student has a GPA'; ?>

index.php
<?php
$studentOneName = 'Dave';
$studentOneGPA = 3.8;

$studentTwoName = 'Treasure';
$studentTwoGPA = 4.0;

//Place your code below this comment
if ($studentOneName > 4.0) {
  echo 'Dave has a GPA of 4.0';

} elseif ($studentTwoName < 3.8) {
  echo 'Treasure has a GPA of 3.8'; {

  } else {
    echo 'Student has a GPA';
?>
Teacher Russell
Teacher Russell
16,873 Points

One thing, you're comparing the $studentName with the GPA, instead of the $studentGPA. Look closely at your comparison. One more thing. Something's missing at the very end of your conditional. A closing bracket:)

1 Answer

Thank you for youre answer I missed the end tag.

Teacher Russell
Teacher Russell
16,873 Points

It's a good habit to always open and close your tags before you put anything in them. It's a simple mistake everyone makes. It's easier to see when it's someone else's code:) Do you see the problems with the conditional? Just re-watch the videos a few times to take it all in. Play with the code in Workspaces. Have fun!