2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2003-05-04 17:13:07 +00:00
|
|
|
<!-- $Revision: 1.4 $ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- 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 set</refpurpose>
|
|
|
|
</refnamediv>
|
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
<methodsynopsis>
|
2003-01-21 19:10:29 +00:00
|
|
|
<type>bool</type><methodname>empty</methodname>
|
2002-04-15 00:12:54 +00:00
|
|
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
|
|
|
<note>
|
|
|
|
<para>
|
|
|
|
<function>empty</function> is a language construct.
|
|
|
|
</para>
|
|
|
|
</note>
|
2003-05-04 17:13:07 +00:00
|
|
|
¬e.language-construct;
|
2002-04-15 00:12:54 +00:00
|
|
|
<para>
|
|
|
|
This 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>
|
|
|
|
|
|
|
|
<!-- Returns &false; if <parameter>var</parameter> is set and has a
|
|
|
|
non-empty or non-zero value; &true; otherwise. -->
|
|
|
|
|
|
|
|
<informalexample>
|
|
|
|
<programlisting role="php">
|
|
|
|
<![CDATA[
|
|
|
|
$var = 0;
|
|
|
|
|
|
|
|
if (empty($var)) { // evaluates true
|
|
|
|
echo '$var is either 0 or not set at all';
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!isset($var)) { // evaluates false
|
|
|
|
echo '$var is not set at all';
|
|
|
|
}
|
|
|
|
]]>
|
|
|
|
</programlisting>
|
|
|
|
</informalexample>
|
|
|
|
|
|
|
|
<simpara>
|
|
|
|
Note that this is meaningless when used on anything which isn't a
|
|
|
|
variable; i.e. <command>empty (addslashes ($name))</command> has
|
|
|
|
no meaning since it would be checking whether something which
|
|
|
|
isn't a variable is a variable with a &false; value.
|
|
|
|
<!-- will even result in parse error (at least in PHP 4) -->
|
|
|
|
</simpara>
|
|
|
|
<simpara>
|
|
|
|
See also <function>isset</function> and
|
|
|
|
<function>unset</function>.
|
|
|
|
</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
|
|
|
|
-->
|