Home > Backend Development > PHP Tutorial > 解析PHP中empty is_null和isset的测试_PHP

解析PHP中empty is_null和isset的测试_PHP

WBOY
Release: 2016-06-01 12:05:12
Original
1005 people have browsed it

代码如下:
复制代码 代码如下:
$a;
$b = false;
$c = '';
$d = 0;
$e = null;
$f = array();

首先是empty的var_dump输出:
boolean true
boolean true
boolean true
boolean true
boolean true
boolean true

然后是is_null的输出:
boolean true
boolean false
boolean false
boolean false
boolean true
boolean false

最后是isset的输出:
boolean false
boolean true
boolean true
boolean true
boolean false
boolean true
由此可见 empty() 可以用来判定所有的数据类型是否为空或假,而 is_null 与 isset 基本一样,只能用来判断是否为NULL和未定义.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template