freeCodeCamp/guide/chinese/php/if-else-statement/index.md

47 lines
798 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

---
title: If-else Statement
localeTitle: If-else声明
---
## 介绍
如果/ Else是条件陈述其中取决于条件的真实性将执行不同的动作。
> **注意:**仅当条件具有多个操作语句时才需要`{}`括号。
## 如果声明
```
if (condition){
statement1;
statement2;
}
```
> **注意:** `else`语句是可选的。
>
> ## 如果/ Else声明
```
if (condition){
statement1;
statement2;
}
else{
statement3;
statement4;
}
```
## 如果/ Elseif / Else声明
```
if (condition){
statement1;
statement2;
}
elseif{
statement3;
statement4;
}
else
statement5;
```
有关更多信息,请查看以下链接: [PHP Else](http://php.net/manual/en/control-structures.elseif.php)