登录

用户名:

密码:
TypeOf(x)     
作者:nsr131421
发部日期:Tue, 04/17/2007

返回变量的类型

<cfscript>
/**
 * Returns the type of the variable.
 * Made it cf5/mx compat with use of getFunctionList
 *
 * @param x   The data to inspect. (Required)
 * @return Returns a string.
 * @author Jordan Clark (JordanClark@Telus.net)
 * @version 3, August 16, 2002
 */
function TypeOf(x) {
   if(isArray(x)) return "array";
   if(isStruct(x)) return "structure";
   if(isQuery(x)) return "query";
   if(isSimpleValue(x) and isWddx(x)) return "wddx";
   if(isBinary(x)) return "binary";
   if(isCustomFunction(x)) return "custom function";
   if(isDate(x)) return "date";
   if(isNumeric(x)) return "numeric";
   if(isBoolean(x)) return "boolean";
   if( listFindNoCase( structKeyList( GetFunctionList() ), "isXMLDoc" ) AND
isXMLDoc(x)) return "xml";
   if(isSimpleValue(x)) return "string";
   return "unknown"; 
}
</cfscript>

<cfscript>
function foo() { return; }
foo2 = createDate( 2002, 4, 1 );
foo3 = Tobinary( ToBase64( "foo" ) );
</cfscript>
<cfoutput>
#typeof( foo )#<br>
#typeof( foo2 )#<br>
#typeof( foo3 )#<br>
</cfoutput>

最后更新:Tue, 04/17/2007