PHP: empty - Manual in Deutsh
PHP: empty - Manual in French
PHP: empty - Manual in Polish

You Are At PHP: empty - Manual Area


recent searches:
include functions , variable functions , post functions...




If you are new to PHP or just need to refresh your skills, this is the place to start. This series of tutorials will give you the basic knowledge you will need to create a simple PHP website.

PHP is a reflective programming language originally designed for producing dynamic web pages.[1] PHP is used mainly in server-side scripting, but can be used from a command line interface or in standalone graphical applications. Textual User Interfaces can also be created using ncurses.

PHP Manual
PrevNext

empty

(PHP 3, PHP 4, PHP 5)

empty -- Determine whether a variable is empty

Description

bool empty ( mixed var )

Determine whether a variable is considered to be empty.

Parameters

var

Variable to be checked

Note: empty() only checks variables as anything else will result in a parse error. In other words, the following will not work: empty(trim($name)).

empty() is the opposite of (boolean) var, except that no warning is generated when the variable is not set.

Return Values

Returns FALSE if var has a non-empty and non-zero value.

The following things are considered to be empty:

"" (an empty string)
0 (0 as an integer)
"0" (0 as a string)
NULL
FALSE
array() (an empty array)
var $var; (a variable declared, but without a value in a class)

ChangeLog

VersionDescription
PHP 5

As of PHP 5, objects with no properties are no longer considered empty.

PHP 4

As of PHP 4, The string value "0" is considered empty.

Examples

Example 1. A simple empty() / isset() comparison.

<?php
$var
= 0;

// Evaluates to true because $var is empty
if (empty($var)) {
    echo
'$var is either 0, empty, or not set at all';
}

// Evaluates as true because $var is set
if (isset($var)) {
    echo
'$var is set even though it is empty';
}
?>

Notes

Note: Because this is a language construct and not a function, it cannot be called using variable functions

See Also

isset()
unset()
array_key_exists()
count()
strlen()
The type comparison tables

Karma pedigree - Najlepsza dla twojego zwierzaka
fotograf ślubny lublin
raty
forma spółki
Wykaz informacyjny dodaj stronę

Another Useful functions:


zend-macro.return-empty-unicode | zend-macro.return-empty-string | zend-macro.return-empty-binary | zend-api.zend-u-hash-add-empty-element | zend-api.zend-hash-add-empty-element | migration4.empty | function.empty |


PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. If you are new to PHP and want to get some idea of how it works, try the introductory tutorial. After that, check out the online manual, and the example archive sites and some of the other resources available in the links section.