<?php
bool is_null ( mixed $value )
where,
$value = VARIABLE to test
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
var_dump
to display the variable as is
- - - - - - - - - - - - - - - - - - - - - - - */
var_dump($_SERVER['REMOTE_ADDR']);
echo '<br><br>';
var_dump($_SERVER['HTTP_USER_AGENT']);
echo '<br><br>';
var_dump($_SERVER['HTTP_ACCEPT_LANGUAGE']);
echo '<br><br>';
var_dump(M_E);
echo '<br><br>';
$x04p = 1.6e-19;
var_dump($x04p);
$arr07 = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
echo '<br><br>';
var_dump($arr07);
$varN01 = NULL;
echo '<br><br>';
var_dump($varN01);
echo '<br><br>';
$varf01 = false;
$varF01 = FALSE;
$vart01 = true;
$varT01 = TRUE;
var_dump($varf01);
echo '<br><br>';
var_dump($varT01);
echo '<br><br>';
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
if -> conditional evaluation
to display if the variable
is a NULL VALUE
This code displays adverse results
as it uses only one statement
- - - - - - - - - - - - - - - - - - - - - - - */
$var01 = $_SERVER["REMOTE_ADDR"];
$var02 = $_SERVER["HTTP_USER_AGENT"];
$var03 = $_SERVER["HTTP_ACCEPT_LANGUAGE"];
$var04 = M_E;
$x04p = 1.6e-19;
$arr07 = [ "c" => 299792458, "G" => 6.67428E-11 ];
$varN01 = NULL;
$varf01 = false;
$varF01 = FALSE;
$vart01 = true;
$varT01 = TRUE;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(is_null($varN01))
// statement 1
var_dump($varN01);
echo "<br>IS NULL<br><br>";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(is_null($arr07))
// statement 1
var_dump($arr07);
echo "<br>IS NULL<br><br>";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(is_null($x04p))
// statement 1
var_dump($x04p);
echo "<br>IS NULL<br><br>";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(is_null($varf01))
// statement 1
var_dump($varf01);
echo "<br>IS NULL<br><br>";
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if(is_null($varT01))
// statement 1
var_dump($varT01);
echo "<br>IS NULL<br><br>";
?>
<?php
/* - - - - - - - - - - - - - - - - - - - - - - -
This is a simple example using
an user-defined function
to display if the variable
is a NULL VALUE
This code displays correct results
as it uses two statements
- - - - - - - - - - - - - - - - - - - - - - - */
$var01 = $_SERVER['REMOTE_ADDR'];
$var02 = $_SERVER['HTTP_USER_AGENT'];
$var03 = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
$var04 = M_E;
$x04p = 1.6e-19;
$arr07 = [ 'c' => 299792458, 'G' => 6.67428E-11 ];
$varN01 = NULL;
$varf01 = false;
$varF01 = FALSE;
$vart01 = true;
$varT01 = TRUE;
function isnull($var)
{
if(is_null($var))
{
// statement 1
var_dump($var);
echo '<br>is NULL<br><br>';
}
else
{
// statement 2
var_dump($var);
echo '<br>is NOT NULL<br><br>';
}
}
isnull($var01);
isnull($var04);
isnull($arr07);
isnull($varN01);
isnull($x04p);
isnull($varF01);
isnull($varT01);
?>