php-doc-en/reference/var/functions/empty.xml

82 lines
2.3 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- 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>
<type>bool</type><methodname>empty</methodname>
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
</methodsynopsis>
<note>
<para>
<function>empty</function> is a language construct.
</para>
</note>
&note.language-construct;
<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
-->