PHP中的asset, empty
在PHP中,isset和empty一般用在if语句里判断变量是否为空,如if (isset($a)), if (empty($b)),还有另一种if($c), if($a == null)。这三种方式究竟怎么用呢?我一般使用isset判断一个非array变量,用empty来判断array变量。这里有一篇文章描述isset和empty的区别:http://www.cnblogs.com/qiantuwuliang/archive/2009/11/09/1599047.html
我自己写了简单的代码来测试,结果如下。貌似后三种效果是一样的。
if(isset($a))if(empty($a))if(!$a)$a==nullundefinedfalsetruetruetrue0truetruetruetrue''truetruetruetruenullfalsetruetruetruearray()truetruetruetrue
页:
[1]