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

Empty

Empty is a language structure, which determines whether a variable is empty.

A variable is considered empty if it does not exist or if its value equals false. This may overlap with the usage of isset().

empty() has an error suppression feature, that masks various errors, such as undefined offset or undefined variables. Some other errors, like an invalid type as offset, are still reported.

<?php

    // True
    var_dump(empty($a));
    
    $b = [];
    // True
    var_dump(empty($b));

?>

Documentation

See Also