---
title: If-else Statement
---
## Introduction
If/Else is a conditional statement where depending on the truthiness of a condition, different actions will be performed.
> **Note:** The `{}` brackets are only needed if the condition has more than one action statement; however, it is best practice to include them regardless.
## If Statement
```
**Note:** You can nest as many statements in an "if" block as you'd like; you are not limited to the amount in the examples.
## If/Else Statement
```
**Note:** The `else` statement is optional.
## If/Elseif/Else Statement
```
**Note:** `elseif` should always be written as one word.
## Nested If/Else Statement
```
**Note:** It's a good practice to wrap individual conditions in parens when you have more than one (it can improve readability).
## Ternary Operators
Another important option to consider when using short If/Else statements is the ternary operator.
```php
$statement=(condition1 ? "condition1 is true" : "condition1 is false");
```
## Alternative If/Else Syntax
There is also an alternative syntax for control structures
```php
if (condition1):
statement1;
else:
statement5;
endif;
```
#### More Information:
* PHP Alternative syntax for control structures
* php.net control structures If Manual
* php.net control structures Else If Manual