PHP is_null,empty,isset,unset The difference in detail _php tutorial

Source: Internet
Author: User
Tags true true
is_null, Empty, isset, unset Let's take a look at the descriptions of these 4 functions first.

Isset to determine if a variable already exists (config)
unset Delete (release) the variable
Empty to determine if the variable is null
Is_null to determine if a variable is null
OK, it's starting to get people. So start, these 4 functions in addition to unset, the other 3 is the judgment function, unset first out, because he will not be mistaken, followed by is_null, we can see it as!isset, is a reverse operation of isset, the following table can be very clear about their relationship:
Copy the Code code as follows:
Variable Empty is_null isset
$a = "" True false True
$a =null true True false
var $a true true false
$a =array () True false true
$a =false true false true
$a =15 false False true
$a =1 false False true
$a =0 true false true
$a = "0" true false true
$a = "true" false false true
$a = "false" false false true


From this we can find that as long as the variable is "" or 0, or false and null, as long as these values are empty will return true, and isset is to determine whether the variable exists, as long as you this variable is not NULL or unassigned, the return result is true, and Is_ Null is exactly the inverse of the isset.

Of course if only want to do the following work:
echo!isset ($_get[' a '); If you don't get the value of variable a
echo Empty ($_get[' a ']); If the value of variable A is empty

Then the results are the same and can all be used.

http://www.bkjia.com/PHPjc/326913.html www.bkjia.com true http://www.bkjia.com/PHPjc/326913.html techarticle is_null, Empty, isset, unset Let's take a look at the descriptions of these 4 functions first. Isset determine if the variable already exists (config) unset Delete (release) the variable to determine whether the variable is ...

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