您现在的位置是:首页 > PHP技术PHP技术
php变量布尔值验证详细参考
2018-03-20【PHP技术】2702 人已围观
简介使用 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:
很赞哦! ()
相关文章
随机图文
Thinkphp更新数据时间字段的插入
thinkphp在处理数据写入数据库时同时记录操作时间,可以用$arr['add_time'] = time();或date...
mysql常见的多表查询语句
select*fromTable1,Table2whereTable1.id=1andTbale2.id-2(是某一相同字段)注意这样的查询...
Thinkphp5.1.30 Session使用笔记
原生PHP使用session过程<?php session_start(); session("username&q...
PHP中对mysql数据表初始化id
一般在数据表中对id是主键是自动递增,在一些临时数据表中,因为对数据的频繁读取删除造成id递增越来越大.我们使用以下二个命令可以初始化my...




微信收款码
支付宝收款码