PHP Conditions

Example 1: if/else condition

The score is 82. The score is passing.

Example 2: switch/case condition

The day is Saturday. It is the weekend.

Explanation

Conditions let a program choose which instructions to run based on a value. The if/else example checks whether a score reaches 70 and then selects one of two messages. The switch example compares a day with multiple cases. A matching case sets the message, break stops further checks, and default handles days that did not match an earlier case.

Back to Activity 3