PHP empty () function detailed _php tutorial

Source: Internet
Author: User
Today is about the use of the empty function, and what the difference between, and use it to manipulate the array is not return the normal value, the need for friends can refer to.

The code is as follows Copy Code
$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

###############################

The code is as follows Copy Code
$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));

is actually
Empty ($x) equals!isset ($x) | | ! $x
!empty ($x) equals isset ($x) && $x

About the empty function syntax

Empty--Check if a variable is null
Describe
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.

http://www.bkjia.com/PHPjc/632256.html www.bkjia.com true http://www.bkjia.com/PHPjc/632256.html techarticle today is about the use of the empty function, and what the difference between, and use it to manipulate the array is not return the normal value, the need for friends can refer to. Code ...

  • 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.