Eigendecomposition PHP Empty checks if a variable is empty

Source: Internet
Author: User
empty-checks if a variable is empty
Report a bug description
BOOL Empty (mixed $var)
If Var is a non-null or nonzero value, empty () returns FALSE. In other words, "", 0, "0", NULL, FALSE, Array (), Var $var; and objects that do not have any properties will be considered empty and return TRUE if Var is empty.
Empty () is the antonym of (Boolean) Var, except that it does not produce a warning when the variable has no value. See Convert to Boolean for more information.
Example #1 A simple comparison of empty () and isset ().

Copy the Code code as follows:


$var = 0;
The result is true because the $var is empty
if (empty ($var)) {
Echo ' $var is either 0 or isn't set at all ';
}
The result is false because the $var has been set
if (!isset ($var)) {
Echo ' $var is not set at all ';
}
?>


Note: Because it is a language constructor and not a function, it cannot be called by a mutable function.
Note:
Empty () detects only variables and detects anything that is non-variable will result in parsing errors. In other words, the statement behind will not work: Empty (Addslashes ($name)).
The following things is considered to be empty:
"" (An empty string)
0 (0 as an integer)
0.0 (0 as a float)
"0" (0 as a string)
Null
FALSE
Array () (an empty array)
var $var; (a variable declared, but without a value in a class)
Understanding of "empty arrays": Array () (an empty array)

Copy the Code code as follows:


$array 1=array ();
Print_r ($array 1);
if (Empty ($array 1)) {
Echo ' is an empty array (an empty array) for empty ();
}
else{
Echo ' is a non-empty array (an Noempty array) for empty ();
}
?>
displaying results: ######################
Array
(
)
For empty () is an empty array
###############################
$array 1=array ();
$array 1[]= ';
Print_r ($array 1);
if (Empty ($array 1)) {
Echo ' is an empty array (an empty array) for empty ();
}
else{
Echo ' is a non-empty array (an Noempty array) for empty ();
}
?>
displaying results: ######################
Array
(
[0] = =
)
is a non-empty array (an Noempty array) for empty ()
//###############################
This is not an empty array, because it has an element that is a null character (""), to be aware of the difference from the null character ("" (An empty string));

The above describes the eigendecomposition php empty check whether a variable is empty, including the eigendecomposition aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Related Article

    Contact Us

    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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.