In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail how to use if-else syntax and NULL data types in PHP. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
If-else syntax in PHP
If and else syntax is an important syntax in PHP. It is recommended that you must master it skillfully. If statement is the simplest one in process control. Only determine whether a condition is true, and if so, execute a specific block of statements.
There are four basic grammars for if and else syntax:
If statement: a single line of code that executes when the condition is true (that is, when the condition is true). The code example is as follows:
In practical use, we often have to execute more than one piece of code, at this time, a simple piece of code can no longer satisfy us, so when writing multiple lines of code, we only need to wrap the code in curly braces {} to represent the whole; if there is only one statement to execute, you can omit the braces mark. Then another basic grammar can be extended:
Multiple lines of code executed when the condition is true (that is, when the condition is true).
If...else statement, in practical use, it is not enough to have only one condition that is true, so there is also an if else statement, which can judge not only the condition is true, but also the condition is false. A single line of code executed when the condition is true (that is, when the condition is true) and another single line of code executed when the condition is not true (that is, when the condition is false). The code example is as follows:
Multiple lines of code executed when the condition is true (that is, when the condition is true).
If...else statement-multiple lines of code executed when the condition is true (that is, when the condition is true) and another multiline of code executed when the condition is not true (that is, when the condition is false).
Then the actual synthesis, for example, is as follows:
Variable assignment is true, so output the code when the condition is established in the if conditional statement, that is, study hard and make progress every day.
Output result:
Null type of php data type
NULL is a special data type in PHP. It has only one value, NULL, which represents a null value (the variable has no value), and it does not represent spaces.
The value of the variable is NULL when the following conditions are met:
The variable is specified as the NULL value
Output result:
Before the variable is assigned, the default value is NULL
Output result:
After you delete a variable using the unset () function, the value of the variable is also NULL.
Output result:
Two functions related to NULL: empty () and isset ()
Pass in a variable in parentheses of empty (), and if the value of this variable is flase or null, then the output is true. Examples are as follows:
Output result:
From this, you can see that the variable an is passed out the true as null through empty ().
One or more variables are passed in between the isset () parentheses, and variables are separated by commas. False is returned as long as one variable is null. Otherwise, true is returned. Examples are as follows:
One variable:
The output is as follows:
Multiple variables:
The output is as follows:
From this you can see that after isset (), multiple variables with null in it are transmitted out of flase.
This is the end of this article on "how to use if-else syntax and NULL data types in PHP". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.