PHP Conditions

If/Else Condition Example

The student passed the class.

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 chooses between different actions based on a condition. A switch statement compares one value with multiple possible cases and runs the code associated with the matching case.