top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use for empty() and is_null() in php?

+1 vote
395 views

Also, tell me the difference between them.I know about empty() function(It will used to check whether the variable is empty or not).I wonder to know what's the main use for is_null() function.

posted Oct 6, 2014 by Madhavi Latha

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

empty()

 empty — Determine whether a variable is empty

In other words, it will return true if the variable is an empty string, false, array(), NULL, “0?, 0, and an unset variable.

is_null()

is_null — Finds whether a variable is NULL

In other words, it returns true only when the variable is null. is_null() is opposite of isset(), except for one difference that isset() can be applied to unknown variables, but is_null() only to declared variables.

The table below is an easy reference for what these functions will return for different values. The blank spaces means the function returns bool(false).

answer Oct 8, 2014 by Vrije Mani Upadhyay
...