您现在的位置是:首页 > PHP技术PHP技术
php变量布尔值验证详细参考
2018-03-20【PHP技术】2503 人已围观
简介使用 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:
很赞哦! ()
相关文章
随机图文
在HTML中引入css的其中的两个方法
1在HTML中引入css的其中的两个方法1.1 使用链接式link href="style.css" rel="...
高级php程序员需要具备的技能
有网友问高级PHP程序员需要具备哪些技能,应该怎么学习?殷雯小编认为初级的php程序员具备开发和前端。高级的程序员应该是开发+前端+运维。既...
Thinkphp5.1上传文件判断问题
指定上传表单名称 $file = request()->file('表单内名称')上面是tp5.1中上传文件时的接收方...
PHP str_pad函数使用注意点
定义和用法str_pad() 函数把字符串填充为新的长度。语法str_pad(string,length,pad_string,pad_ty...




微信收款码
支付宝收款码