cfset
Description
Sets a value in ColdFusion. Used to create a variable, if it does not exist, and assign it a value. Also used to call functions.
Category
Variable manipulation tags
Syntax
Usage
You use the cfset tag in several ways in your applications.
Calling functions
When you use the cfset tag to call a function, you do not have to assign the function return value to a variable if the function does not return a value or you do not have to use the value returned by the function. For example, the following line is a valid ColdFusion cfset tag for deleting the Myvariable variable from the Application scope:
Arrays
The following example assigns a new array to the variable months:
This example creates a variable Array_Length that resolves to the length of the Scores array:
This example assigns, to index position two in the array months, the value February:
Dynamic variable names
In this example, the variable name is itself a variable:
<cfset "#myvariable#" = 5>