Home > Uncategorized > PHP's empty()

PHP's empty()

Two quick notes on the use of the empty() function in PHP.

1) It’s actually a language construct, not a function.

2) As per #1, you can’t do things like

if ( empty( array_intersect( $array1, $array2, $array3 ) ) ) {
    ...
}

If you try, PHP will break with no error message, and you’ll waste approximately two hours trying to figure out why the rest of your function is wrong, when it’s not.

  1. No comments yet.