In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use empty in php", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use empty in php" article.
In php, empty means "empty", is a built-in function to check whether a variable is empty, the syntax "empty ($var)"; when a variable value is 0, empty string, "0.0", "0", NULL, FALSE, empty array, empty () thinks that the variable is equal to empty.
Operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
Empty means "empty".
Empty () is a built-in function in php that determines whether a variable is "empty".
Empty also detects whether the variable is empty or zero. When the value of a variable is 0 zero empty (), the variable is considered to be equivalent to empty, which means that it is not set.
Example:
$id=0;empty ($id)? print "It's empty.": print "It's $id."; / / result: It's empty .print "
";! isset ($id)? print" It's empty. ": print" It's $id. "; / / result: It's 0.
When a variable does not exist, or when its value is equal to FALSE, then it is considered nonexistent. Empty () does not generate a warning if the variable does not exist.
Note: prior to PHP 5.5, empty () only supported variables; anything else would cause a parsing error. In other words, the following code will not take effect:
Empty (trim ($name))
Instead, you should use:
Trim ($name) = = false
Empty () does not generate a warning, even if the variable does not exist. This means that empty () is essentially equivalent to! isset ($var) | | $var = = false.
Return value:
Returns FALSE if var exists and is a non-empty non-zero value. Otherwise, TRUE is returned.
The following variables are considered empty:
"" (empty string)
0 (0 as an integer)
0.0 (as 0 of a floating point number)
"0" (as 0 of the string)
NULL
FALSE
Array () (an empty array)
$var; (a variable that is declared but has no value)
Example:
Output:
$ivar1 is empty or 0. The $istr1 string is not empty or 0. The above is about the content of this article on "how to use empty in php". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please follow the industry information channel.
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.