我有:
<cfif not isDefined(activity)>
<cfset activity="">
</cfif>
我收到错误:&#34;变量ACTIVITY未定义。&#34;
咦?
哦,错误是isDefined
,而不是cfset
。
答案 0 :(得分:9)
isDefined takes the name of a variable,而不是变量本身:
<cfif not isDefined("activity")>
<cfset activity="">
</cfif>
答案 1 :(得分:4)
尝试:
<cfif structKeyExists(VARIABLES, 'Activity')>
<cfset Activity = "Something" />
</cfif>