Today, We want to share with you isset vs empty vs is_null in PHP Example.In this post we will show you wordpress plugin require another plugin, hear for PHP: Test the value of a variable using isset() vs empty() vs is_null() we will give you demo and example for implement.In this post, we will learn about Determine if a variable is set and is not NULL with an example.
isset vs empty vs is_null in PHP Example
There are the Following The simple About PHP isset() vs empty() vs is_null() in PHP Full Information With Example and source code.
As I will cover this Post with live Working example to develop difference between PHP isset() vs empty() vs is_null(), so the php check if string is empty or whitespace is used for this example is following below.
PHP isset() vs empty() vs is_null()
“” | “tamilrokers” | NULL | FALSE | 0 | undefined | |
empty() | TRUE | FALSE | TRUE | TRUE | TRUE | TRUE |
is_null() | FALSE | FALSE | TRUE | FALSE | FALSE | ERROR |
isset() | TRUE | TRUE | FALSE | TRUE | TRUE | FALSE |
PHP Source Code to Understand the Difference
[php]
ISSET:
“;
$param = “”;
print “isset():”. isset($param).”
“;
$param = “tamilrokers”;
print “isset(‘tamilrokers’):”. isset($param).”
“;
$param = NULL;
print “isset(‘NULL’):”. isset($param).”
“;
$param = FALSE;
print “isset(‘FALSE’):”. isset($param).”
“;
$param = 0;
print “isset(‘0’):”. isset($param).”
“;
print “isset(undefined):”. isset($var3).”
“;
print “
EMPTY:
“;
$param = “”;
print “empty():”. empty($param).”
“;
$param = “tamilrokers”;
print “empty(‘tamilrokers’):”. empty($param).”
“;
$param = NULL;
print “empty(‘NULL’):”. empty($param).”
“;
$param = FALSE;
print “empty(‘FALSE’):”. empty($param).”
“;
$param = 0;
print “empty(‘0’):”. empty($param).”
“;
print “empty(undefined):”. empty($var1).”
“;
print “
IS_NULL:
“;
$param = “”;
print “is_null():”. is_null($param).”
“;
$param = “tamilrokers”;
print “is_null(‘tamilrokers’):”. is_null($param).”
“;
$param = NULL;
print “is_null(‘NULL’):”. is_null($param).”
“;
$param = FALSE;
print “is_null(‘FALSE’):”. is_null($param).”
“;
$param = 0;
print “is_null(‘0’):”. is_null($param).”
“;
print “is_null(undefined):”. is_null($var2).”
“;
?>
[/php]
isset() – isset — Determine if a variable is set and is not NULL
[php]