VOOZH about

URL: https://www.geeksforgeeks.org/php/how-to-check-whether-a-variable-is-null-in-php/

⇱ How to check Whether a Variable is Null in PHP? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to check Whether a Variable is Null in PHP?

Last Updated : 21 Apr, 2025

We are given a variable and the task is to check whether the value of the given variable is null or not and returns a Boolean value using PHP.

To check a variable is null or not, we use is_null() function. A variable is considered to be NULL if it does not store any value. It returns TRUE if the value of variable $var is NULL, otherwise, returns FALSE.

Syntax:

boolean is_null( $var )

Example: This example checks whether a variable is null in PHP or not.

Output:

True
False
False
Comment
Article Tags: