PHP | is_null() Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The is_null() function is an inbuilt function in PHP which is used to find whether a variable is NULL or not. Syntax: boolean is_null ( $var ) Parameters: This function accepts a single parameter as shown in above syntax and described below. $var: Variable to check if it is NULL or not. Return value: It returns a boolean value. That is, it returns TRUE when $var will be NULL, otherwise it returns FALSE. Below programs illustrate the is_null() function in PHP: Program 1: PHP <?php // PHP code to demonstrate the working of is_null() function $var1 = NULL; $var2 = "\0"; // "\0" means "\0" $var3 = "NULL"; $var4 = 0; // $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"); // $var4 is 0, gives FALSE is_null($var4) ? print_r("True\n") : print_r("False\n"); ?> Output: True False False False Program 2: PHP <?php // PHP code to demonstrate the working of // is_null() function function check_null($var) { return (is_null($var) ? "True" : "False"); } echo check_null(NULL) . "\n"; echo check_null(null) . "\n"; echo check_null(Null) . "\n"; echo check_null(NUll) . "\n"; echo check_null(NULl) . "\n"; echo check_null(nulL) . "\n"; echo check_null(nuLL) . "\n"; echo check_null(nULL) . "\n"; echo check_null(Nul) . "\n"; echo check_null(false) . "\n"; ?> Output: True True True True True True True True False False Reference: https://www.php.net/manual/en/function.is-null.php Create Quiz Comment M Mithun Kumar Follow 0 Improve M Mithun Kumar Follow 0 Improve Article Tags : Misc Web Technologies PHP PHP-function Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like