Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • PHP Tutorial
  • PHP Exercises
  • PHP Array
  • PHP String
  • PHP Calendar
  • PHP Filesystem
  • PHP Math
  • PHP Programs
  • PHP Array Programs
  • PHP String Programs
  • PHP Interview Questions
  • PHP GMP
  • PHP IntlChar
  • PHP Image Processing
  • PHP DsSet
  • PHP DsMap
  • PHP Formatter
  • Web Technology
Open In App
Next Article:
PHP | is_null() Function
Next article icon

PHP | is_null() Function

Last Updated : 05 Oct, 2021
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: http://php.net/manual/en/function.is-null.php
 


Next Article
PHP | is_null() Function

M

Mithun Kumar
Improve
Article Tags :
  • Misc
  • Web Technologies
  • PHP
  • PHP-function
Practice Tags :
  • Misc

Similar Reads

    PHP | is_link( ) Function
    The is_link() function in PHP used to check whether the specified file is a symbolic link or not. The path to the file is sent as a parameter to the is_link() function and it returns TRUE if the filename exists and is a symbolic link, otherwise it returns FALSE. Syntax: is_link(file) Parameters Used
    2 min read
    PHP is_long() Function
    The is_long() function is an inbuilt function in PHP that is used to check whether the given value is a long integer or not. Syntax: bool is_long(mixed $value) Parameters: This function accepts a single parameter $value that holds the value which needs to check for a long integer. Return Value: This
    1 min read
    PHP | is_numeric() Function
    The is_numeric() function is an inbuilt function in PHP which is used to check whether a variable passed in function as a parameter is a number or a numeric string or not. The function returns a boolean value. Syntax: bool is_numeric ( $var ) Parameters: The function accepts a single parameter which
    2 min read
    PHP | is_a() function
    The is_a() is a built-in function in PHP and is used to check whether a given object is of a given class or not. It also checks if the given class is one of the parents of the given object or not. Syntax: boolean is_a($object, $class) Parameters: This function accepts two parameters as shown in the
    2 min read
    PHP isset() Function
    The isset() function in PHP checks whether a variable is declared and not NULL. It returns true if the variable exists and has a non-NULL value, and false otherwise, without modifying the variable. Syntaxbool isset( mixed $var [, mixed $... ] )Parameters: This function accept one or more parameter a
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences