Creating ColdFusion variables using variables

05/19/2011 in How To

Once thing I really like about ColdFusion that many other languages do not support is the ability to create variables using variables..


For example:
 
<cfset v="name">
 
<cfset "first#v#"="David">
 
This creates a variable called firstname.

<cfoutput>#firstname#</cfoutput>

This would output:
 
David
 
Easy. Used creatively, this functionality enables you to really create some real cool code. So what are you waiting for, go get creative!
 
Enjoy..
 
Add A Comment
Name *
Email Address (Not displayed with comment) *
Comment *
Please enter the text in the image below *
Comments posted are subject to site approval.