47 lines
798 B
Markdown
47 lines
798 B
Markdown
---
|
||
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) |