Consider this example:
Code:
<cfset myVar = "foo">
<cfset myVarName = "myVar">
Obviously, one way to get the value of myVar is #myVar#. But if I don't know what the name of the variable is going to be (which is sometimes the case with query or form variables), I can't do that. I know that the name of the variable is stored in the variable #myVarName#, so I need a way to say to the ColdFusion engine, "Take the value of the variable 'myVarName', then evaluate that as the name of another variable". Since ColdFusion doesn't speak english, exactly, we have the Evaluate() function to tell it to do that. One way to accomplish the above example would be:
Code:
#Evaluate("#myVarName#")#
Which says (from inside out):
[ol][li]Extract the value of the variable myVarName (which is a string).[/li]
[li]Treat that string like it was the name of a variable, and get the value of that variable.[/li][/ol]
In ColdFusion documentation, this is known as
Dynamic Evaluation. There's a simpler way to write the Evaluate() function, which takes advantage of the fact that anywhere a function or expression expects a string in quotes, it will take an unquoted variable name instead:
So this evaluates not the string "myVarName", (which in this example evaluates to "myVar"), but the value of the variable "myVarName" ("myVar", which evaluates to "foo").
Hope this helps out.