★ wanayoo — archive 1999 http://www.php.net/manual/de/function.empty.phpNouvelle recherche | Portail wanayoo

PHP Home Page

Manual Table of Contents
Up to Variablen
Quick Reference
English version of this pageJapanese version of this pageItalian version of this pageFrench version of this pageHungarian version of this page
Variablen
* call_user_func
* call_user_method
* doubleval
* empty
* gettype
* intval
* is_array
* is_bool
* is_double
* is_float
* is_int
* is_integer
* is_long
* is_object
* is_real
* is_resource
* is_string
* isset
* print_r
* settype
* strval
* unset
* var_dump
Manual: empty
View the source code for this pageSearch the site



Previous page
 doubleval
 Updated
Sat, 12 Aug 2000
gettype 
Next page


empty

(unknown)

empty -- Prüft, ob eine Variable einen Wert enthält

Beschreibung

int empty (mixed var)

Diese Funktion liefert true, wenn eine Variable nicht definiert, leer oder gleich 0 ist, ansonsten false.


$var = 0;
if (empty ($var)) { #evaluates true 
    print '$var is either 0 or not at all set';
}
if (!isset ($var)) { // evaluates false
    print 'The $var is not set at all';
}
      

empty() kann nur auf Variablen, nicht aber auf Ausdrücke angewandt werden.

Siehe auch isset() und unset().


User Contributed Notes: empty


Akihiro SAGAWA <sagawa@sohgoh.net>
13-Feb-2000 11:00
This function also return true when the array is empty.
i.e.
<PRE>
&lt;?php
$foo = array();
if (empty($foo)) print "empty!!\n"; /* prints "empty!!" */
?>
</PRE>



griffon9@hotmail.com
13-Mar-2000 05:52
As of PHP4 beta 4, this function behaves differently with PHP3 and PHP4 :
$a='0';
echo(empty($a));

returns false (0) with PHP3 and true (1) with PHP4...



carl@wurb.com
14-May-2000 07:06
It should be borne in mind that the word "variable" as used in this manual generally means, not just a bare variable name like "$foo", but anything that can be assigned a value. (In other words, what in some languages is called an "lvalue".) Thus, "empty($obj->property)" and "empty($arr[12])" are valid.



strider@atlantis-tech.com
01-Jul-2000 07:16
Bone headed move guys! In php<4, if a form variable was not set in the form, empty($var) would return true. Now, empty($var) returns false.

$var = '0'; //php4 sets $var to 0 from a form even if it was not set on the form

empty($var) evaluates to TRUE in php<4
empty($var) evaluates to FALSE in php4

Argghhh!



ccjeagle@ms6.hinet.net
08-Aug-2000 09:45
php4.0.1pl2
&lt;?
$a = 0 ; print empty($a) ? "TRUE" : "FALSE"; //TRUE
$b = "0" ; print empty($b) ? "TRUE" : "FALSE"; //TRUE
$c = "" ; print empty($c) ? "TRUE" : "FALSE"; //TRUE
$d = 1 ; print empty($d) ? "TRUE" : "FALSE"; //FALSE
print empty($e) ? "TRUE" : "FALSE"; //TRUE
$f= TRUE ; print empty($f) ? "TRUE" : "FALSE"; //FALSE
$g= FALSE; print empty($g) ? "TRUE" : "FALSE"; //TRUE
$h=array();print empty($h) ? "TRUE" : "FALSE"; //TRUE
?>



 About Notes


Previous page
 doubleval
 Updated
Sat, 12 Aug 2000
gettype 
Next page





Who's responsible for this?
Top of this page

Site
Hosting:



Located in
United States
Elements of this website are subject to copyright.
Questions about installing or using PHP should be directed to one of the mailing lists.
Only questions about the website should be directed to webmaster@php.net.