ASP 空字符串、IsNull、IsEmpty区别分析
网络编程 2021-07-05 10:58www.168986.cn编程入门
本文将详细介绍ASP中空字符串、IsNull、IsEmpty之间的区别,有需要的朋友可以参考下
说明:set aa=server.createobject("ddd")
isnull 说明指针为空,指针指到一个无效的位置,即对象不存在,
isempty 说明指针指向一个有效位置,但是值为空
1、空字符串
例:
a)Dim strTmp
response.write(strTmp="") ' 返回true
b)response.write(str="") ' 返回 true
c)Dim strTmp
strTmp=""
response.write(strTmp="") ' 返回 true
这几行代码说明ASP中无论是没做过声明的变量还是做个声明但没有赋值的变量ASP都认为是空字符串或叫做零长度字符串。
2、IsEmpty()
如果变量未初始化或显式地设置为 Empty,则函数 IsEmpty 返回 True;
否则函数返回 False。如果 expression 包含一个以上的变量,总返回 False。
例:
a)Dim strTmp
Response.Write(IsEmpty(strTmp)) ' 返回 True
b)Dim strTmp
strTmp = Null
Response.Write(IsEmpty(strTmp)) ' 返回 Flase
c)Dim strTmp
strTmp = Empty
Response.Write(IsEmpty(strTmp)) ' 返回 True
d)Dim strTmp
strTmp = ""
Response.Write(IsEmpty(strTmp)) ' 返回 Flase
3、IsNull()
Null 值指出变量不包含有效数据。Null 与 Empty 不同,后者指出变量未经初始化。Null 与零长度字符串 ("") 也不同,零长度字符串往往指的是空串。
使用 IsNull 函数可以判断表达式是否包含 Null 值。
例:
a)Dim strTmp
Response.Write(IsNull(strTmp)) ' 返回 False
b)Response.Write(IsNull(strTmp)) ' 返回 False 注意这里strTmp是一个未经声明的变量
a)Dim strTmp
strTmp = Null
Response.Write(IsNull(strTmp)) ' 返回 True
a)Dim strTmp
strTmp = Empty
Response.Write(IsNull(strTmp)) ' 返回 False
isnull 说明指针为空,指针指到一个无效的位置,即对象不存在,
isempty 说明指针指向一个有效位置,但是值为空
1、空字符串
例:
代码如下:
a)Dim strTmp
response.write(strTmp="") ' 返回true
b)response.write(str="") ' 返回 true
c)Dim strTmp
strTmp=""
response.write(strTmp="") ' 返回 true
这几行代码说明ASP中无论是没做过声明的变量还是做个声明但没有赋值的变量ASP都认为是空字符串或叫做零长度字符串。
2、IsEmpty()
如果变量未初始化或显式地设置为 Empty,则函数 IsEmpty 返回 True;
否则函数返回 False。如果 expression 包含一个以上的变量,总返回 False。
例:
代码如下:
a)Dim strTmp
Response.Write(IsEmpty(strTmp)) ' 返回 True
b)Dim strTmp
strTmp = Null
Response.Write(IsEmpty(strTmp)) ' 返回 Flase
c)Dim strTmp
strTmp = Empty
Response.Write(IsEmpty(strTmp)) ' 返回 True
d)Dim strTmp
strTmp = ""
Response.Write(IsEmpty(strTmp)) ' 返回 Flase
3、IsNull()
Null 值指出变量不包含有效数据。Null 与 Empty 不同,后者指出变量未经初始化。Null 与零长度字符串 ("") 也不同,零长度字符串往往指的是空串。
使用 IsNull 函数可以判断表达式是否包含 Null 值。
例:
代码如下:
a)Dim strTmp
Response.Write(IsNull(strTmp)) ' 返回 False
b)Response.Write(IsNull(strTmp)) ' 返回 False 注意这里strTmp是一个未经声明的变量
a)Dim strTmp
strTmp = Null
Response.Write(IsNull(strTmp)) ' 返回 True
a)Dim strTmp
strTmp = Empty
Response.Write(IsNull(strTmp)) ' 返回 False
编程语言
- 机械手焊接机器人编程 机械手焊接设备编程
- vb数据库编程实例,vb做数据库
- tiobe世界编程语言排行榜,全球编程语言排行
- 成都java编程培训 成都it编程培训中心
- 编程基础培训,编程基础知识培训
- flash游戏编程基础教程,flash游戏开发教程
- 不会英语能学编程吗 不会英语可以学程序员吗
- 爱心代码编程C语言 爱心代码编程c语言公式
- c语言编程学习入门 c语言编程快速入门
- 西门子plc编程培训 西门子plc编程培训班
- 哪里可以学编程 台州哪里可以学编程
- 少儿编程哪个好 少儿编程哪个品牌好
- 编程是什么意思,图形编程是什么意思
- c语言编程软件下载,c语言编程软件在哪下载
- java编程软件下载,java编程下载手机版
- ug编程培训学校,ug编程培训教程