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

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,872 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,872 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!