ColdFusion是定义获取未定义错误

时间:2014-12-16 23:48:03

标签: coldfusion

我有:

<cfif not isDefined(activity)>
    <cfset activity="">
</cfif>

我收到错误:&#34;变量ACTIVITY未定义。&#34;

咦?

哦,错误是isDefined,而不是cfset

2 个答案:

答案 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>