Small caveat to rh's post: back in PHP 3, "0" would be considered non-empty (i.e., empty would return false), even though (bool) on "0" would also evaluate to false; thus, they would not be complete opposites for someone using PHP 3.
![]() | is_bool描述bool is_bool ( mixed var )如果 var 是 boolean 则返回 TRUE。
参见 is_array()、is_float()、is_int()、is_integer()、is_string() 和 is_object()。 ![]()
21-Apr-2006 07:12
Small caveat to rh's post: back in PHP 3, "0" would be considered non-empty (i.e., empty would return false), even though (bool) on "0" would also evaluate to false; thus, they would not be complete opposites for someone using PHP 3.
rh at richardhoward dot net
23-May-2005 02:17
punkpuke is wrong here; what he means to say is that empty($x) is the opposite of (bool)$x. is_bool($x) returns true where $x === false.
| ![]() | |