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

No Such Function As Empty

<?php

// bool(true)
var_dump(empty(null));

//Fatal error: Uncaught Error: Call to undefined function empty() 
var_dump(\empty(null));

There is no function called empty(), which could be accessed using a fully qualified name, such as \empty. There is also no function that can be defined as such, since empty() is already taken.

When the code needs to pass around a empty function, the best approach is to wrap a call to the empty() language construct, in a closure.

See Also

PHP Features

Last updated: 09 November 2026