php if variable is null code example
Example 1: is null php
// 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.
<?php
$var = NULL;
if (is_null($var)) {
echo "yes, is null";
} else {
echo "not null";
}
?>
Example 2: php check for null
is_null($foo)
Example 3: php check for empty string
if (empty($var)) {
echo '$var is either 0, empty, or not set at all';
}
Example 4: is null php
is_null($var)