Skip to content

Instantly share code, notes, and snippets.

@kpirnie
Created August 13, 2025 18:12
Show Gist options
  • Save kpirnie/c93bf874ccea0f07e0b4f05b849f8ef9 to your computer and use it in GitHub Desktop.
Save kpirnie/c93bf874ccea0f07e0b4f05b849f8ef9 to your computer and use it in GitHub Desktop.
PHP - Is It Really Empty?
/**
* is_it_empty
*
* Gets whether a variable is empty, null, or 'null'
*
* @since 7.4
* @access public
* @static
* @author Kevin Pirnie <[email protected]>
* @package Kevin's Spam Stop
*
* @return bool Returns if the variable testing is empty, null, or 'null'
*
*/
public static function is_it_empty( $_val ) : bool {
// return from the test
return ( ( empty( $_val ) ) || ( is_null( $_val ) ) || ( 'null' === $_val ) ) ?: false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment