PHP isset() vs empty() vs is_null()
来源:互联网 发布:青少年编程网 编辑:程序博客网 时间:2024/06/11 09:25
PHP isset() vs empty() vs is_null()
PHP has different functions which can be used to test the value of a variable. Three useful functions for this areisset(),empty() and is_null(). All these function return a boolean value. If these functions are not used in correct way they can cause unexpected results.
isset() and empty() are often viewed as functions that are opposite, however this is not always true. In this post I will explain the differences between these functions.
isset()
From PHP manual – isset():
isset — Determine if a variable is set and is not NULL
In other words, it returns true only when the variable is not null.
empty()
From PHP Manual – empty():
empty — Determine whether a variable is empty
In other words, it will return true if the variable is an empty string, false, array(), NULL, “0?, 0, and an unset variable.
is_null()
From PHP Manual – is_null():
is_null — Finds whether a variable is NULL
In other words, it returns true only when the variable is null. is_null() is opposite of isset(), except for one difference that isset() can be applied to unknown variables, but is_null() only to declared variables.
- PHP 7.0.4
- PHP 5.6.19
- PHP 5.5.33
Download Source Code
- PHP isset() vs empty() vs is_null()
- PHP isset() vs empty() vs is_null()
- PHP isset(),empty(),is_null()
- php empty isset is_null
- php empty() isset() is_null()
- php empty,isset,is_null比较
- php中empty() isset() is_null()函数比较
- php empty(), isset(), is_null() 实例测试
- php中empty() isset() is_null() 的区别
- php中empty(), is_null(), isset()函数区别
- php is_null,isset,empty函数的区分
- PHP中isset、empty、is_null实验测试
- PHP empty isset is_null区别比较
- php中empty(), is_null(), isset()函数区别
- PHP中 is_null、empty、isset的区别
- php中is_null,isset,empty的总结
- is_null, empty, isset, unset
- empty is_null isset
- Apache跨域访问
- php函数方法知识
- 1.7算法入门之最佳存款方案
- lightoj 1105 - Fi Binary Number 水
- jquery折线图组件终极版
- PHP isset() vs empty() vs is_null()
- 转-10软件测试工作总结
- 常用第三方汇总
- Java中调用sqlServer的存储过程的几种简单情况
- SQL ROW_NUMBER() 的用法
- Linux_用户级_常用命令(1)
- java初学者常见的问题
- Win7 64位下PowerDesigner连接64位Oracle11g数据库
- php学习 SQL注入 2016.03.29回顾