In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what does the multi-branch of php refer to". In the daily operation, I believe that many people have doubts about what the multi-branch of php refers to. The editor consulted all kinds of materials and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubt of "what does the multi-branch of php refer to?" Next, please follow the editor to study!
The multi-branch in php refers to the multi-directional conditional branch structure of PHP; in PHP, the elseif clause is a typical multi-directional conditional branch, which extends the if statement, and the elseif clause determines which statement block to execute according to different expression values; in PHP, elseif can also be divided into two keywords, elseif.
The operating environment of this paper: Windows7 system, PHP7.1, Dell G3.
What does php mean by multiple branches?
PHP branch control statement, branch structure of PHP process control structure
Process control is universal and universal for any programming language, and it is an important part of the program. It can be said that in any programming language, there are three basic structures that need to be supported: sequential structure, branch structure (choice structure or conditional structure), and loop structure. For sequential structures, mainly assignment statements and input / output statements, which are executed sequentially, there is nothing to say here. Here, the author focuses on summarizing the branch structure and loop structure.
Branching structure
Branch structure is the order in which a program changes its execution order according to the requirements during its execution. That is, one narrative block is executed when the condition is met, and otherwise another narrative block is executed. The use of branch structures in programs can take the following forms:
Single conditional branching structure bidirectional conditional branching structure multidirectional conditional branching structure nested conditional branching structure
Single conditional branch
The if structure is a single conditional branch structure. The basic format of the if statement is to evaluate an expression and decide whether or not to execute the following statement according to the result of the evaluation. The "expression" in parentheses after if is the condition for execution, and the result returned by the condition can only be a Boolean value. It is usually the result value calculated by an expression consisting of comparison operators or logical operators, or some functions that return Boolean, and so on. If a value of another type is passed in, it is also automatically converted to a Boolean TRUE or FALSE. If the expression is TRUE, the code block is executed, otherwise it is not executed.
DEMO
Bidirectional conditional bifurcation
A two-way conditional branch, like an if statement, can also contain an else clause, which means that one statement needs to be executed when a condition is met, and other statements are executed when the condition is not met, which is the function of the else clause. Else extends the if statement to execute the statement when the value of the expression in the if statement is FALSE. It is worth noting that the else statement is a clause of the if statement and must be used with if and cannot exist alone.
DEMO
Multidirectional conditional bifurcation
The elseif clause is a typical multi-directional conditional branch, which extends the if statement, and the elseif clause determines which statement block to execute according to different expression values. In PHP, you can also separate elseif into two keywords, elseif. The execution order is that if the expression l is TRUE, the code block 1 statement is executed; if the expression 2 is judged to be TRUE, the code block 2 statement is executed; and so on, if the nth expression is judged to be TRUE, then the code block n statement is executed; if the condition of the expression is not TRUE, the code block n statement in the else sub-language is executed, of course, the final else statement can also be omitted.
DEMO
Like elseif, switch statement is also a multi-directional conditional branching structure, but if and elseif statements use Boolean expressions or Boolean values as branching conditions for branching control, while switch statements are used to test the value of an expression and choose to execute the corresponding branch program according to the test results, so as to achieve branching control. The switch statement consists of a selection expression and multiple case tags, followed by a block of code immediately after the case tag. The following points should be noted when using the switch statement:
The data type of the selection expression after the switch statement can only be an integer or a string, not a Boolean. Usually this control expression is a variable name.
Curly braces after the switch statement are required.
The number of case statements is not specified and can be increased indefinitely. But there should be a space between the case tag and the value that follows it, and the value must be followed by a colon, which is part of the syntax.
After the switch matching is complete, the statements in the matching branch module are executed one by one until the end of the switch structure or the break statement is encountered.
The default tag in the switch statement is directly followed by a colon, which means that the value of the expression cannot be equal to the value after any of the previous case tags, and the statement in the default branch is executed. The default tag can be omitted.
DEMO
Nest conditional branching
The nested conditional branching structure is the nesting of if statements, that is, the code block after if or else contains if statements.
DEMO
At this point, the study of "what does the multi-branches of php refer to" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.