|
12 | 12 | <methodparam><type>mixed</type><parameter>var</parameter></methodparam> |
13 | 13 | </methodsynopsis> |
14 | 14 | <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. |
16 | 16 | </para> |
17 | 17 | </refsect1> |
18 | 18 | <refsect1 role="parameters"> |
|
29 | 29 | <para> |
30 | 30 | <function>empty</function> only checks variables as anything else will |
31 | 31 | 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>. |
33 | 34 | </para> |
34 | 35 | </note> |
35 | 36 | <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>. |
39 | 40 | </para> |
40 | 41 | </listitem> |
41 | 42 | </varlistentry> |
|
45 | 46 | <refsect1 role="returnvalues"> |
46 | 47 | &reftitle.returnvalues; |
47 | 48 | <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;. |
50 | 51 | </para> |
51 | 52 | <para> |
52 | 53 | The following things are considered to be empty: |
|
58 | 59 | <member>&null;</member> |
59 | 60 | <member>&false;</member> |
60 | 61 | <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> |
62 | 63 | </simplelist> |
63 | 64 | </para> |
64 | 65 | </refsect1> |
|
0 commit comments