In PHP, what is the difference between is_null
and ==null
in PHP? What are the qualifications for both to return true?
$x === nullNull is a special data type in PHP which can have only one value that is NULL. A variable of data type NULL is a variable that has no value assigned to it. Any variable can be empty by setting the value NULL to the variable.
The is_null() function checks whether a variable is NULL or not. This function returns true (1) if the variable is NULL, otherwise it returns false/nothing.
In PHP, a variable with no value is said to be of null data type. Such a variable has a value defined as NULL. A variable can be explicitly assigned NULL or its value been set to null by using unset() function.
NULL essentially means a variable has no value assigned to it; false is a valid Boolean value, 0 is a valid integer value, and PHP has some fairly ugly conversions between 0 , "0" , "" , and false . Show activity on this post. Null is nothing, False is a bit, and 0 is (probably) 32 bits.
is_null
is the same as === null
. Both return true when a variable is null
(or unset).
Note that I'm using ===
and not ==
. ===
compares type as well as value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With