每个变量都在某个范围内,而且(大多数)只是一个结构.
所以,你可以structKeyExists()
像这样使用:
<!--- If your variable is in VARIABLES scope --->
<cfif structKeyExists(VARIABLES, "firstWordCategory")>
<!--- Your Code --->
</cfif>
Run Code Online (Sandbox Code Playgroud)
小智 5
要检查任何变量是否存在,可以使用isDefined
函数:
<cfif isDefined("firstWordCategory")>
<cfoutput>#firstWordCategory#</cfoutput>
</cfif>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请检查此。