PHP to determine whether the variable is null

1, is_null isset and
these two functions can be determined whether a variable is null, they empty string, 0, false identity is the same.
Is_null to = isset ()!;

The difference is that isset grammatical structure, is_null is a function. In terms of performance, grammatical structure is relatively little good. So many places recommended isset instead of using is_null
2, and == ===

In some cases, it is recommended to use isset to determine whether a variable is null
but syntactically speaking, a variable "display has been initialized" and "not null" is a different concept, using isset in some scenarios are inappropriate , such as a function to check whether the return value is null.

At this point you can use the "==" and "===" to determine whether they are null
for the "==" and "===", they direct the difference is still very large. For the "==", it recognized an empty string, 0, false are Null. As for the "===" is really only one variable is null, null it was on behalf of
another "===" relative to isset, the performance is better

3, it is determined whether a variable is null directly "===" can be a
4, empty the contents of a variable is determined whether the stored zero or null, 0, "0", null , false, array (), var $ var, and no properties of objects are considered to be empty, it represents a zero.

If a value of $ a is undefined or NULLL, $ a = NULL, it must be empty, i.e. empty ($ a) = true; if $ a is an int, $ a = 0, with respect to number, 0 representatives zero, i.e. empty ($ a) = true;
if $ a is a string type, $ a = "", with respect to the character string, "" on behalf of a blank, i.e. empty ($ a) = true; if $ a is string type, $ a = "0", with respect to the character string, "0" is represents zero, i.e. empty ($ a) = true;
if $ a is bool type, $ a = false, relatively true, false on Representative blank, i.e. empty ($ a) = true; if $ a is of type array, $ a = array (), the array is relatively speaking, there is no data element is empty, i.e. empty ($ a) = true;

Guess you like

Origin www.cnblogs.com/xiong-hua/p/12119336.html