免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1457 | 回复: 0
打印 上一主题 下一主题

判断php变量是否定义,是否为空,是否为真的一览表 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-05-03 03:36 |只看该作者 |倒序浏览

使用 PHP 函数对变量 $x 进行比较
表达式
gettype()
empty()
is_null()
isset()
boolean
: if($x)
$x = "";
string
TRUE
FALSE
TRUE
FALSE
$x = null;
NULL
TRUE
TRUE
FALSE
FALSE
var $x;
NULL
TRUE
TRUE
FALSE
FALSE
$x is undefined
NULL
TRUE
TRUE
FALSE
FALSE
$x = array();
array
TRUE
FALSE
TRUE
FALSE
$x = false;
boolean
TRUE
FALSE
TRUE
FALSE
$x = true;
boolean
FALSE
FALSE
TRUE
TRUE
$x = 1;
integer
FALSE
FALSE
TRUE
TRUE
$x = 42;
integer
FALSE
FALSE
TRUE
TRUE
$x = 0;
integer
TRUE
FALSE
TRUE
FALSE
$x = -1;
integer
FALSE
FALSE
TRUE
TRUE
$x = "1";
string
FALSE
FALSE
TRUE
TRUE
$x = "0";
string
TRUE
FALSE
TRUE
FALSE
$x = "-1";
string
FALSE
FALSE
TRUE
TRUE
$x = "php";
string
FALSE
FALSE
TRUE
TRUE
$x = "true";
string
FALSE
FALSE
TRUE
TRUE
$x = "false";
string
FALSE
FALSE
TRUE
TRUE

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/40795/showart_1916542.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP