Home > Backend Development > PHP Tutorial > PHP:empty,isset,is_null,array(0),array(),array(""),0,"0","","null",NULL的总结

PHP:empty,isset,is_null,array(0),array(),array(""),0,"0","","null",NULL的总结

WBOY
Release: 2016-06-23 13:29:19
Original
774 people have browsed it

通过下面这个程序来检测

$a=0;if(empty($a)){	echo "yes|";}else{	echo "no|";}if(isset($a)){	echo "yes|";}else{	echo "no|";}if(is_null($a)){	echo "yes|";}else{	echo "no|";}if($a){	echo "yes|";}else {	echo "no|";}
Copy after login

那么$a 分别取不同值的时候结果如下



总结:

empty的情况

1变量的值为空 $var = “”;

2变量的值为字符串0或者数字0  $var = 0 ; 或者$var =”0″

3变量的值为flase $var= flase;

4凡是为NULL的 都为空

5空数组  $arr =array();

6变量只定义不赋值$var;

isset的情况

查看一个变量是否已经被设置并且不为空(Determine if a variable is set and is not NULL)

is_null

判断null

判断是否为假

1变量的值为空 $var = “”;

2变量的值为字符串0或者数字0  $var = 0 ; 或者$var =”0″

3变量的值为flase $var= flase;

4凡是为NULL的 都为空

5空数组  $arr =array();

6变量只定义不赋值$var;

这些全假

版权声明:本文为博主原创文章,未经博主允许不得转载。

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