This article mainly introduces the description of the PHP empty () function, has a certain reference value, now share to everyone, the need for friends can refer to
On the face of it, it is easy to misunderstand that the empty () function is a function that determines whether a string is empty, in fact it is not, I eat a lot of losses.
The empty () function is used to test whether a variable has been configured. Returns False if the variable already exists, a non-empty string, or nonzero, and returns a true value. So, when the value of the string is 0 o'clock, it also returns True, which is the statement inside the empty. This is the trap.
such as: suppose $value = 0; Then empty ($value) =false.
Advise everyone, be careful to use the empty () function.
Judging if the string is empty, you can say so: if ($value = = "") ...
* Format: BOOL empty (mixed Var)
* Function: Check if a variable is empty
* Return value:
* Returns TRUE if the variable does not exist
* If the variable exists and its value is "", 0, "0", NULL, FALSE, Array (), Var $var; and objects that do not have any properties, the TURE is returned.
* If the variable exists and the value is not "", 0, "0", NULL, FALSE, Array (), Var $var; And an object that does not have any properties, it returns FALSE
* Version: PHP 3, PHP 4, PHP 5
On the face of it, it is easy to misunderstand that the empty () function is a function that determines whether a string is empty, in fact it is not, I eat a lot of losses. The empty () function is used to test whether a variable has been configured. Returns False if the variable already exists, a non-empty string, or nonzero, and returns a true value. So, when the value of the string is 0 o'clock, it also returns True, which is the statement inside the empty. This is the trap. such as: suppose $value = 0; Then empty ($value) =false. Advise everyone, be careful to use the empty () function. Judging if the string is empty, you can say so: if ($value = = "") ... Format: bool Empty (mixed Var) function: Checks whether a variable is a null return value: Returns TRUE if the variable does not exist if the variable exists and its value is "", 0, "0", NULL, FALSE, Array (), Var $var; and objects that do not have any properties, return TURE if the variable exists and the value is not "", 0, "0", NULL, FALSE, Array (), Var $var; and an object without any attributes, it returns FALSE version: Php 3, PHP 4, PHP 5
<table width= "760" border= "1" align= "Center" cellpadding= "3" > <? $dir = './201006/24/'; $object [] = @readdir ($dir); foreach ($object as $dirail) if (empty ($dirail)) {?> <tr> <td align= "center" ><font color= " Red > No pictures </font></td> </tr> <?} else {?> <tr> <td align= "Center "><font color=" Red "> Directory with pictures </font></td> </tr> <?}?> </table>
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!