Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Nullable

Nullable is the name of the NULL value, when used as a type. Until PHP 8.0, it was marked as a question mark with types, and since PHP 8.0, it is also marked with its own name, as a union type.

<?php

    // argument has the short nullable type
    // return type has the long form nullable type
    function foo(?A $a) : null | B {
        // code
    }

?>

Documentation

See Also