PHP Conditions

If/Else Condition Example

You are 18 or older.

Switch/Case Example

Today is Monday.

Explanation

Conditions allow a PHP program to make decisions based on whether something is true or false. An if/else statement checks a condition and chooses between two different sets of instructions. A switch statement compares one value with different cases and runs the code for the matching case. Conditions help a webpage respond differently to different values and situations.

Back to Activity 3