<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.7 $ -->
<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
  <refentry id="function.empty">
   <refnamediv>
    <refname>empty</refname>
    <refpurpose>Determine whether a variable is empty</refpurpose>
   </refnamediv>
   <refsect1>
    <title>Description</title>
     <methodsynopsis>
      <type>bool</type><methodname>empty</methodname>
      <methodparam><type>mixed</type><parameter>var</parameter></methodparam>
     </methodsynopsis>
    <para>
     <function>empty</function> returns &false; if
     <parameter>var</parameter> has a non-empty or non-zero value.  In
     otherwords, <literal>""</literal>, <literal>0</literal>,
     <literal>"0"</literal>, &null;, &false;, <literal>array()</literal>,
     <literal>var $var;</literal>, and objects with empty properties, are
     all considered empty.  &true; is returned if <parameter>var</parameter>
     is empty.  
    </para>
    <para>
     <function>empty</function> is the opposite of
     <literal>(boolean) <parameter>var</parameter></literal>,
     except that no warning is generated when the variable is not set.
     See <link linkend="language.types.boolean.casting">converting
     to boolean</link> for more information.
    </para>
    <para>
     <example>
      <title>
       A simple <function>empty</function> / <function>isset</function>
       comparison.
      </title>  
      <programlisting role="php">
<![CDATA[
<?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';
}
?>
]]>
      </programlisting>
     </example>
    </para>

    &note.language-construct;
    
    <note>
     <para>
      <function>empty</function> only checks variables as anything else will
      result in a parse error.  In otherwords, the following will not work:
      <command>empty(addslashes($name))</command>.
     </para>
    </note>
    <simpara>
     See also <function>isset</function>,
     <function>unset</function>,
     <function>array_key_exists</function>,
     <function>count</function>, 
     <function>strlen</function>, and
     <link linkend="types.comparisons">the type comparison tables</link>.
    </simpara>
   </refsect1>
  </refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->