文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>检测变量类型

检测变量类型

时间:2007-02-17  来源:PHP爱好者

之前说过 VBScrpit 是不需要事先定义变数类型的,程式自己会帮你决定最适当的类型。但如果我们想知道现在变数内到底储存的是什么类型的值,有两个函数非常有用:
·VarType(variable_name) 
·TypeName(variable_name) 
传入的值都是一个变数。VarType 会传回这个变数所储存值的类型代码,TypeName 则会传回类型的名称。 看看下面的程式:
<% Option Explicit %>
<%
Dim strName, iAge

Response.Write "<p>设定值之前,strName 的类型是:"
Response.Write TypeName(strName)
Response.Write "
此类型的代号为:"
Response.Write VarType(strName)

strName = "小正正"
iAge = 24

Response.Write "<p>现在 strName 的类型是:"
Response.Write TypeName(strName)
Response.Write "
此类型的代号为:"
Response.Write VarType(strName)

Response.Write "<p>现在 iAge 的类型是:"
Response.Write TypeName(iAge)
Response.Write "
此类型的代号为:"
Response.Write VarType(iAge)
%>
输出的结果是:
设定值之前,strName 的类型是:Empty此类型的代号为:0 现在 strName 的类型是:String此类型的代号为:8现在 iAge 的类型是:Integer此类型的代号为:2
php爱好者站 http://www.phpfans.net PHP|MySQL|javascript|ajax|html.
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载