PHP Conditions

Example 1: If/Else Condition

Your score is 85. You passed the course.

Example 2: Switch/Case Condition

Today is Monday. It is the beginning of the school week.

Explanation

Conditions allow a PHP program to make decisions based on whether certain requirements are true or false. An if/else statement chooses between two possible actions. A switch statement compares one value with different cases and runs the code for the matching case. The break statement stops PHP from continuing into the next case.

Back to Activity 3 Home