PHP If Else
PHP If Else statement is used to test condition. The following steps are various ways to use if statement.
- if
- if-else
- if-else-if
- nested if
PHP If Statement
It allows conditional execution of code. If the condition is true this statement is executed.
if(condition){
//code to be executed
}

PHP If-else Statement
PHP if-else statement is executed whether the condition is true or false.
if(condition){
//code to be executed if true
}else{
//code to be executed if false
}

PHP If-else-if Statement
The PHP if-else-if is a special statement used to combine multiple if else statements.
if (condition1){
//code to be executed if condition1 is true
} elseif (condition2){
//code to be executed if condition2 is true
} elseif (condition3){
//code to be executed if condition3 is true
....
} else{
//code to be executed if all given conditions are false
}

PHP nested if Statement
The nested if statement contains the if block inside another if block.
if (condition) {
//code to be executed if condition is true
if (condition) {
//code to be executed if condition is true
}
}
