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: 14 July 2026