Jump to content

Trying to understand the logic of the if and else statement


levanthai

Recommended Posts

Hey guys!

Thanks for your patience here... I know that I still have a lot to learn but I am trying to understand some of the basic of the if and else statement.... I have two separate codes and the first one is part of a longer code but not how to find out which part of the {} I should put the else statement, I guess I shouldn't be guessing at all.... thanks!

Link to comment
Share on other sites

Student was given assignment to RTFM.

Student was graded on assignment using a simple question/answer sheet.

Teacher graded students question/answer sheet and put grade into a variable called $student_grade

<

if($student_grade === "Passed"){

//student passed question/answer sheet so....

echo "Great job, you RTFM";

}

else{

//student failed question/answer sheet so....

echo "You did not RTFM";

}

>

Link to comment
Share on other sites

An if -else construct branches on the truthiness of the condition.

 

if (condition) {
  // This block executes if condition evaluates as TRUE
} else {
  // This block executes if condition evaluates as FALSE
}

Note that in PHP the condition must be enclosed within parens  ie.  ().  There is really nothing more to it than that.  If you have a more specific question, let us know.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.