PHP Conditions

Example 1: If/Else Condition

Enter your age:

Example 2: PHP Switch/Case

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

Explanation

Conditions allow PHP programs 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 against several different cases and runs the code belonging to the matching case. Conditions help websites respond differently depending on user input or data.


Back to Activity 3 Home Page