In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
How to understand else in php, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
In php, else means "other", and the else statement is a clause of the if statement, which can be executed when the value of the expression in the if statement is FALSE; the else statement must be used with the if statement and cannot exist alone. Syntax "if (judgment condition) {statement block 1;} else {statement block 2;}".
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
If statements can only perform operations on cases where the result is true, which is not enough in many cases, so there is a statement in the form of if...else. Different from the if judgment, the if...else statement performs operations not only on cases where the result is true, but also on cases that are not true.
The else statement extends the if statement, which can be executed when the value of the expression in the if statement is FALSE. It is also important to note that the else statement is a clause of the if statement and must be used with the if statement and cannot exist alone.
The syntax format of the if...else statement is as follows:
If (judgment condition) {statement block 1;} else {statement block 2;}
In the above format, if the judgment condition is true, statement Block 1 is executed; otherwise, statement Block 2 is executed. both statement Block 1 and statement Block 2 can contain multiple statements. Like the if statement, if both statement Block 1 and statement Block 2 contain only one statement, you can omit the curly braces {}, as shown below:
If (judgment condition) statement block 1 control else statement block 2
The execution flow of the if...else statement is shown in the following figure:
Example: use the rand () function to generate a random number $num, and then determine whether the random number is even or odd, the code is as follows:
The running results are as follows:
$num = 27, is odd!
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.