Discover if else statement example, include the articles, news, trends, analysis and practical advice about if else statement example on alibabacloud.com
Conditional statement, which is a kind of statement that chooses to execute according to the condition in the program, the difficulty lies in how to abstract the condition accurately in the actual use of such statement. For example, to implement the
The code we see earlier is executed sequentially, that is, the first statement is executed first, then the second, the third ... Until the last statement.
However, in many cases, sequential structure of the code is far from enough, such as a
Before you introduce the "if" statement, know that the "if" statement is to meet the expression when the execution of a PHP statement, when the condition is not satisfied, is not executed, but, in most cases, always meet the conditions when the
If ... Then ... Else statementConditionally executes a set of statements based on the value of an expression.
If condition Then statements [Else elsestatements]
Or, use block-form syntax:
If condition Then[Statements][ElseIf condition-n
1, if statement
An If statement is an important feature in most languages, and it executes the program segment according to the conditions. PHP's If statement is similar to C:
if (expr)
Statement
As discussed in an expression, expr is computed
If,elseIf if, else is another meaning, if the condition is determined within the parentheses, if the condition is met, the IF statement executes the command and if it does not, the IF statement is not entered.The basic format:①if (...) Conditions
First, If...else statement
If...else statement
Executes a piece of code when the condition is set, and executes another piece of code when the condition is not established
Grammar:
1. Simple condition
if (condition) {......}else{......}
Cases
How to Use the if... else statement in Lua
This article mainly introduces how to use the if... else statement in Lua. It is the basic knowledge of Lua beginners. For more information, see
The if statement can be followed by an optional else
This article mainly introduces the usage of the IF ... else statement in Lua, which is the basic knowledge in Lua's introductory learning, and can be consulted by a friend.
An If statement can be followed by an optional else statement, when the
The IF statement determines which branch to execute by using relational operators to determine whether an expression is true or false. The Shell has three kinds of if ... else statements:
If ... fi statement;
If ... else ... fi
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.