asp中isempty、isnull與空字符串三者之間的區別
isnull 說明指針爲空,指針指到一個無效的位置,即對象不存在,
isempty 說明指針指向一個有效位置,可是值爲空
一、空字符串
例:
a)Dim strTmp
response.write(strTmp="") ' 返回true
b)response.write(str="") ' 返回 true
c)Dim strTmp
strTmp=""
response.write(strTmp="") ' 返回 true
沒有賦值的變量ASP能夠認爲是空字符串或叫作零長度字符串。express
二、IsEmpty()
若是變量未初始化或顯式地設置爲 Empty,則函數 IsEmpty 返回 True;
不然函數返回 False。若是 expression 包含一個以上的變量,總返回 False。
例:
a)Dim strTmp
Response.Write(IsEmpty(strTmp)) ' 返回 True函數
b) Response.Write(IsEmpty(str))' 返回 True
c)Dim strTmp
strTmp = Null
Response.Write(IsEmpty(strTmp)) ' 返回 Flase
d)Dim strTmp
strTmp = Empty測試
Response.Write(IsEmpty(strTmp)) ' 返回 True
e)Dim strTmp
strTmp = ""
Response.Write(IsEmpty(strTmp)) ' 返回 Flasespa
沒有賦值的變量也能夠認爲是Empty 即空值
指針
能夠用isdate,isarray,isnumeric替代isempty進行測試a),b)兩個例子,isnumeric也是返回 True,isdate,isarray返回 False對象
3.empty補充字符串
dim a,b,c,d,e,f,it
a=0io
b=0.0變量
c=""
d=false
e=empty
response.write(x=empty) 'x請用a,b,c,d,e,f其中一個代替,返回都爲true
response.write(isempty(x)) 'x請用a,b,c,d,e,f其中一個代替,除了e,f,其它返回都爲false
四、IsNull() Null 值指出變量不包含有效數據。Null 與 Empty 不一樣,後者指出變量未經初始化。Null 與零長度字符串 ("") 也不一樣,零長度字符串每每指的是空串。 使用 IsNull 函數能夠判斷表達式是否包含 Null 值。 例: a)Dim strTmp Response.Write(IsNull(strTmp)) ' 返回 False b)Response.Write(IsNull(strTmp)) ' 返回 False 注意這裏strTmp是一個未經聲明的變量 c)Dim strTmp strTmp = Null Response.Write(IsNull(strTmp)) ' 返回 True d)Dim strTmp strTmp = Empty Response.Write(IsNull(strTmp)) ' 返回 False