Isset and empty differences: is in PHP

Source: Internet
Author: User
Tags empty functions variable true true

S_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
$a =null true False
var $a true true false
$a =array () True False
$a =false True
$a =15 to False true
$a =1 to False true
$a =0 True
$a = "0" true false
$a = "true" to false true
$a = "false" to false true
From which we can see if 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, so long as you are not NULL or unassigned, the return result is true, and Is_null is exactly the opposite of Isset.
Of course if just 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
So the results are the same, they can be used.
This article links http://www.cxybl.com/html/wlbc/Php/20130729/39379.html

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.