Log in / create account | Login with OpenID
DocForge
Programmer's Wiki

PHP/empty

From DocForge

< PHP

empty is a language construct used to determine if a variable is considered empty.

bool empty ( mixed $var )

empty() is the opposite of (boolean) $var, except that no warning is generated when the variable is not set. Passing anything for $var which is not explicitly a variable will cause a parse error.

empty returns false if var has a non-empty and non-zero value.

The following are considered empty:

  • ""
  • 0
  • "0"
  • Null
  • false
  • array() (an empty array)
  • A variable declared in a class before a value is set

[edit] See Also

Do you have information or insights to contribute to this article? Please feel free to edit this page. Ask questions or contribute to the discussion on this article's talk page.