Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6e3a76b

Browse files
author
Pieter Hordijk
committed
Improved empty() docs
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@326624 c90b9560-bf6c-de11-be94-00142212c4b1
1 parent 1ef6e39 commit 6e3a76b

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

reference/var/functions/empty.xml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
1313
</methodsynopsis>
1414
<para>
15-
Determine whether a variable is considered to be empty.
15+
Determine whether a variable is considered to be empty. A variable is considered empty if it does not exist or if its value equals &false;. <function>empty</function> does not generate a warning if the variable does not exist.
1616
</para>
1717
</refsect1>
1818
<refsect1 role="parameters">
@@ -29,13 +29,14 @@
2929
<para>
3030
<function>empty</function> only checks variables as anything else will
3131
result in a parse error. In other words, the following will not work:
32-
<command>empty(trim($name))</command>.
32+
<command>empty(trim($name))</command>. Instead, use
33+
<command>trim($name) == false</command>.
3334
</para>
3435
</note>
3536
<para>
36-
<function>empty</function> is the opposite of
37-
<literal>(boolean) var</literal>,
38-
except that no warning is generated when the variable is not set.
37+
No warning is generated if the variable does not exist.
38+
That means <function>empty</function> is essentially the
39+
concise equivalent to <command>!isset($var) || $var == false</command>.
3940
</para>
4041
</listitem>
4142
</varlistentry>
@@ -45,8 +46,8 @@
4546
<refsect1 role="returnvalues">
4647
&reftitle.returnvalues;
4748
<para>
48-
Returns &false; if <parameter>var</parameter> has a non-empty
49-
and non-zero value.
49+
Returns &false; if <parameter>var</parameter> exists and has a non-empty, non-zero value.
50+
Otherwise returns &true;.
5051
</para>
5152
<para>
5253
The following things are considered to be empty:
@@ -58,7 +59,7 @@
5859
<member>&null;</member>
5960
<member>&false;</member>
6061
<member><literal>array()</literal> (an empty array)</member>
61-
<member><literal>var $var;</literal> (a variable declared, but without a value in a class)</member>
62+
<member><literal>$var;</literal> (a variable declared, but without a value)</member>
6263
</simplelist>
6364
</para>
6465
</refsect1>

0 commit comments

Comments
 (0)