Conditional statements are used to perform different actions based on different conditions.
In PHP, we have the following conditional statements:
Statement | Description |
---|---|
if | Executes some code if one condition is true |
if ... else | Executes some code if a condition is true and another code if that condition is false |
if ... elseif ... else | Executes different code for more than two conditions |
switch | Selects one of many blocks of code to be executed |