How to check Whether a Variable is Null in PHP? Last Updated : 21 Apr, 2025 Comments Improve Suggest changes Like Article Like Report 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. PHP <?php // PHP Program to check whether // a variable is null or not? $var1 = NULL; $var2 = "\0"; // "\0" means null character $var3 = "NULL"; // $var1 has NULL value, so always give TRUE is_null($var1) ? print_r("True\n") : print_r("False\n"); // $var2 has '\0' value which consider as null in // c and c++ but here taken as string, gives FALSE is_null($var2) ? print_r("True\n") : print_r("False\n"); // $var3 has NULL string value so it will false is_null($var3) ? print_r("True\n") : print_r("False\n"); ?> Output:TrueFalseFalse Comment More infoAdvertise with us Next Article How to check Whether a Variable is Null in PHP? M manaschhabra2 Follow Improve Article Tags : Web Technologies PHP PHP Programs PHP-Misc Similar Reads How to check whether a variable is set or not using PHP ? We have given a variable and the task is to check whether a variable var is set or not in PHP. In order to do this task, we have the following methods in PHP: Approach 1: Using isset() Method: The isset() method returns True if the variable is declared and its value is not equal to NULL. Syntax: boo 2 min read How to check whether an array is empty using PHP? Arrays are commonly used data structures that can hold multiple values. Sometimes it is necessary to check if an array is empty or not, and it is an important task to avoid errors when working with data. PHP offers several easy and effective ways to check if an array is empty. Below are the most com 3 min read PHP | Check if a variable is a function To determine whether a passed argument is a function or not, Few of the most preferred methods are shown below. Using is_callable() Function: It is an inbuilt function in PHP which is used to verify the contents of a variable in called as a function. It can check that a simple variable contains the 3 min read How to read if a checkbox is checked in PHP? Using isset() Function The isset() function is an inbuilt function in PHP which checks whether a variable is set and is not NULL. This function also checks if a declared variable, array or array key has null value, if it does, isset() returns false, it returns true in all other possible cases. This 2 min read How to Check a Value Exist at Certain Index in an Array in PHP? Given an array and index, the task is to check whether a value exists or not at a certain index in an array in PHP. Below are the approaches to check if a value exists at a certain index or not in an array in PHP:Table of ContentUsing isset() FunctionUsing array_key_exists() FunctionUsing key_exists 3 min read Like