As it sounds, the data type which has not been assigned a value is defined as a NULL value . Any variable is considered to be a NULL if:

  • It has been assigned the constant NULL.
  • It has not been set to any value yet.
  • It has been cleared with the function unset()

An example of a NULL data type

<?php
    $var = NULL;
?>

Initializing a variable to NULL using unset(), variable will not remove or unset its value, but it only returns it as a NULL value.

Useful functions when working with NULL values: 

  • The function is_null(), finds whether a variable is NULL or not.
  • The function isset(), determines if a variable is set and is not a NULL.

 

›› go to examples ››