当前位置:网站首页>PHP的empty,isset和is_null区别
PHP的empty,isset和is_null区别
2022-06-21 16:31:00 【健康搬砖人】
PHP提供了三个用于测试变量值的函数,分别是isset(),empty(),is_null(),他们都返回布尔值,但是也有区别。
通过以下表格查看:
| 对比项 | isset()方法 | empty()方法 | is_null方法 |
| ""(空字符串) | true | ture | false |
| " "(一个空格) | true | false | false |
| FALSE | true | true | false |
| TRUE | true | false | false |
| array()(一个空数组) | true | true | false |
| NULL | false | true | true |
| "0"(字符串0) | true | true | false |
| 0(整型0) | true | true | false |
| 0.0(浮点型) | true | true | false |
| $a(未赋值变量) | false | true | false |
1、isset()函数用来检测一个变量是否已声明并且值不为NULL,也就是说只有在值不为NULL时返回真值
2、empty()用来检测一个变量是否为空如果有如下情况返回真值:
1)空字符串
2)false
3)空数组
4)NULL
5)0
6)0.0
7)unset之后的变量
8)字符串0
3、is_null()用来判断变量内容是否是null值,返回真值的条件仅仅是变量为null时,所以他是isset()的反函数,从上表中也可以看出来
边栏推荐
- Not graduated from a first-class university, but passed the self-study software test and entered the initial 22K annual salary of Alibaba
- Hain's law and Feynman's learning method
- Algorithm -- maximum number after parity exchange (kotlin)
- 搜索(集训)
- 【蓝桥杯省赛真题35】Scratch水面倒影 少儿编程scratch编程蓝桥杯省赛真题讲解
- Live broadcast platform development, live broadcast of each category and single example design display
- [Oracle] is there a "time" data type in oracle-- Research on Oracle data types
- LeetCode_ String_ Simple_ 387. first unique character in string
- 【技术管理】集结号与亮剑团队
- Stm32f1 and stm32subeide programming example - linear Hall effect sensor driver
猜你喜欢

Stack awareness - stack overflow instance (ret2libc)

Bm95 points candy problem

STM32F1与STM32CubeIDE编程实例-线性霍尔效应传感器驱动

How to adjust 3DE 3D model view if you can't see it

堆栈认知——栈溢出实例(ret2shellcode)

From demand to open source, how to look at it with new eyes?

Simulation of vector

3DE 运动轮廓数据修改

EtherCAT object dictionary analysis

System V IPC与POSIX IPC
随机推荐
Jetpack compose phase
在线文档协作:办公必备高效率神器
Software test architecture learning and construction (14) - overview of software test and development model of test foundation
EtherCAT igh master station controls Esther servo to return to zero
Hain's law and Feynman's learning method
Iso8191 test is mentioned in as 3744.1. Are the two tests the same?
Interceptor to realize web user login
C语言与Lua的交互(实践二)
tcpserver开启多线程处理
Tcpserver enable multithreading
From demand to open source, how to look at it with new eyes?
EtherCAT igh函数尝试
PTA l3-032 questions about depth first search and reverse order pair should not be difficult (30 points)
是关于Linux中一步建立yum源缓存问题
What is the difference between IEC62133 and EN62133? Which items are mainly tested?
Differences between fragmentstatepageradapter and fragmentpageradapter
现有需求同步其他数据库用户信息到我们系统他们主键id为string我们主键为Long
[Oracle] is there a "time" data type in oracle-- Research on Oracle data types
Not graduated from a first-class university, but passed the self-study software test and entered the initial 22K annual salary of Alibaba
Move Protocol Beta测试版稳定,临时决定奖池规模再扩大