您现在的位置是:首页 > PHP技术PHP技术
php变量布尔值验证详细参考
2018-03-20【PHP技术】2412 人已围观
简介使用 PHP 函数对变量$x进行比较表达式gettype()empty()is_null()isset()boolean:&...
| 表达式 | 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 |
以上是平时开发中的注意事项,有疑问的大家可以验证下哈欢迎指正
细节才是最重要的!
关注宁波网站建设博客,更多精彩分享,敬请期待!
Tags:
很赞哦! ()
相关文章
随机图文
ThinkPHP6.0RC2版本发布啦
一早打开网站看到ThinkPHP6.0RC2版本发布——架构升级、精简核心! 厉害,学的比开发的还要慢! 我们在刚适应从tp3.X到tp5....
thinkphp模板中数组的输出
thinkphp的数组在模版输出是频率很高的操作. 我在后action内一般是把数据都绑定到变量内,当然是以数组的形式.select后的操作...
jQuery中实现prop()函数控制多选框(全选,反选)
jQuery中实现prop()函数控制多选框(全选,反选) 看了jQuery手册,对prop()函数又多了一点认识,记忆力不好,记录下来。...
composer安装thinphp5.1的验证码1
按thinkphp5.1开发手机介绍首先需要使用Composer安装think-captcha扩展包,需要fanqiang哦(当然使用国内...




微信收款码
支付宝收款码