Conditions

Back to index

Example 1: if/else

Score: 78

Result: Pass

Example 2: switch/case

Today is Wednesday.

It's a class day.

Explanation

Conditions allow a PHP program to make decisions based on information. The if/else statement checks whether the score is high enough to pass. The switch/case statement checks the value of the day and runs the matching case. This helps the program show different results depending on the situation. Conditions are useful when a program needs different results for different situations.