NULL
` is a special value that represents a variable with no value or a non-existent value. A variable with a `NULL
` value has been explicitly assigned the `NULL
` value or has not been assigned a value at all.<?php
$name = null;
if (is_null($name)) {
echo "Name is null";
} else {
echo "Name is not null";
}
?>
Name is null
$name
` and assign it the `NULL
` value explicitly. We then use the `is_null()
` function to check if the variable has a `NULL
` value and print a message accordingly.NULL
` values, such as `is_null()
`, `unset()
`, and `empty()
`. The `unset()
` function can be used to unset a variable and remove its value, effectively setting it to `NULL
`.<?php
$name = "John";
unset($name);
if (is_null($name)) {
echo "Name is null";
} else {
echo "Name is not null";
}
?>
Name is null
$name
` and assign it a string value. We then unset the variable using the `unset()
` function and check if it has a `NULL
` value using the `is_null()
` function. The output will be "Name is null
" because the variable `$name
` has been unset and has no value.