The difference between php is_null empty isset unset

Source: Internet
Author: User
Tags empty true true

Echo!isset (get[′a′]);  If the value of variable A is not Echoempty (_get[' a ']); If the value of variable A is null Is_null, empty, isset, unset Let's take a look at the descriptions of these 4 functions first.

Isset determine if a variable already exists (configuration)

unset to remove (release) a variable

Empty determine if the variable is empty

Is_null determine if the variable is null

OK, it's starting to get people started. So start, the 4 functions except unset, the other 3 are the Judge function, unset first out, because he will not be mistaken, followed by is_null, we can see it as a!isset, is the isset of a reverse operation, the following table can be very clear description of their relationship:

 variable empty is_null isset $a = "" True                      False true $a =null true true false Var $a   
True true false $a =array () True to True $a =false true false $a =15 false F                        Alse true $a =1 false to true $a =0                True false $a = ' 0 ' true false               True $a = "true" to false true $a = "false" false False true 

From that we can see that as long as the variable is "" or 0, or false and null, as long as the value empty returns True, and Isset is the judge of whether the variable exists, as long as you are not NULL or unassigned, the return result is true, and Is_ Null is exactly the inverse result of isset.

Of course if just want to do the following work:

Echo!isset (get[′a′]);  If the value of variable A is not Echoempty (_get[' a ']); If the value of variable A is empty

So the results are the same, they can be used.

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/webkf/PHP/

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.