Home >Backend Development >PHP Tutorial >What is the difference between empty and is_null? _PHP Tutorial
What is the difference between empty and is_null?
bool empty ( mixed $var )
If var is a non-empty or non-zero value, empty() returns FALSE. In other words, "", 0, "0", NULL, FALSE, array(), var $var; and objects without any properties will be considered empty, and TRUE is returned if var is empty.
empty() is the antonym of (boolean) var except that it does not produce a warning when the variable is not set. See Converting to Boolean for more information.
///////////////////////////////////////////////////// ///////////////////////////////////////////
A variable is considered NULL in the following situations:
bool is_null ( mixed $var )
Returns TRUE if var is null, FALSE otherwise.
is assigned the value NULL.
has not been assigned a value yet.
is unset().