PHP Conditions

Example 1: If/Else Condition

You are 18 or older.

Example 2: PHP Switch Case

Today is Monday.

Explanation

Conditions allow a PHP program to make decisions based on different situations. An if/else statement checks whether a condition is true or false and runs the appropriate code. A switch statement compares one value with different cases and runs the code for the matching case. This helps programs respond differently depending on the information they receive.

Back to Activity 3 Home