Table of Contents

    Understanding NULL in PHP: Handling Absence of Value

    Understanding NULL in PHP: Handling Absence of Value

    Null is a special data type which can have only one value: NULL.

    A variable of data type NULL is a variable that has no value assigned to it.

    Tip: If a variable is created without a value, it is automatically assigned a value of NULL.

    Variables can also be emptied by setting the value to NULL:

    Syntax:

    
    
    <?php
    $x = "Hello world!";
    $x = null;
    var_dump($x);
    ?>