好的,这个功能没有意义,但我只是以它为例:
<cffunction name="blah">
<cfset var myFoo = 123>
<cfset var varNamePrefix = "my">
<cfset var bar = Evaluate("#varNamePrefix#Foo")>
<cfreturn bar>
</cffunction>
使用CF9,我可以使用local["#varNamePrefix#Foo"]
。有没有办法让CF7 / 8摆脱Evaluate()
而不用var local = structNew()
重构整个事情?
答案 0 :(得分:6)
不是通过文件记录的方式。前CF9只有getPageContext().getActiveFunctionLocalScope()
<cffunction name="blah">
<cfset var myFoo = 123>
<cfset var varNamePrefix = "my">
<!--- ie object.method()[keyName] syntax does not seem to be supported --->
<cfset var localScope = getPageContext().getActiveFunctionLocalScope()>
<cfset var bar = localScope["#varNamePrefix#Foo"]>
<cfreturn bar>
</cffunction>