- In PHP null () function is an inbuilt function which is used to find whether a variable is NULL or not.
- If it returns True the given variable is null, otherwise it returns False.
- If the value of $x is equal to NULL it returns true and it is an identical comparison operator.
- In PHP null is a special data type which can have only one value that is NULL.
- NULL data type is a variable that has no value assigned to it and then any variable can be empty by setting the value NULL to the variable.
Sample Code
[pastacode lang=”php” manual=”%3C!DOCTYPE%20html%3E%0A%3Chtml%3E%0A%3Cbody%3E%0A%0A%3C%3Fphp%0A%24apple%20%3D%200%3B%0Aecho%20%22apple%20is%20%22%20.%20is_null(%24a)%20.%20%22%3Cbr%3E%22%3B%0A%0A%24orange%20%3D%20null%3B%0Aecho%20%22orange%20is%20%22%20.%20is_null(%24b)%20.%20%22%3Cbr%3E%22%3B%0A%0A%24grape%20%3D%20%22null%22%3B%0Aecho%20%22grape%20is%20%22%20.%20is_null(%24c)%20.%20%22%3Cbr%3E%22%3B%0A%0A%24watermelon%20%3D%20NULL%3B%0Aecho%20%22watermelon%20is%20%22%20.%20is_null(%24d)%20.%20%22%3Cbr%3E%22%3B%0A%3F%3E%0A%0A%3C%2Fbody%3E%0A%3C%2Fhtml%3E%0A%0A” message=”” highlight=”” provider=”manual”/]Output

