You use the cffunction tag to define a UDF in CFML. The cffunction tag syntax has the following features and limitations:
- Developers who have a background in CFML or HTML, but no scripting or programming experience will be more familiar with the syntax.
- You can include any ColdFusion tag in your function definition. Therefore, you can create a function, for example, that accesses a database.
- You can embed CFScript code inside the function definition.
- The cffunction tag provides attributes that enable you to easily limit the execution of the tag to authorized users or specify how the function can be accessed.
The following code uses the cffunction tag to define the exponentiation function:
<cffunction name="twoPower" output=True>
<cfargument name="exponent">
<cfreturn 2^exponent>
</cffunction>
For more information on how to use the cffunction tag to define a function, see Defining functions by using the cffunction tag.