Variables in CFML

Variables are the workhorses of any language. They allow for manipulation of values, storage of data and give languages the ability to maintain and control state during processing. To work with any language one of the first things you must learn is how to set and manipulate variables in it.

ColdFusion offers many different kinds (or scopes) and types of variables. Each kind of variable is useful in its own way and each has pros and cons to consider before using it. Except where noted the following information should be considered applicable to ColdFusion versions 4 or greater. Although CFML has matured and evolved greatly over the years the basics rarely change.

I'm going to try and explain this in a clear, understandable way. If you notice an error or would like something further detailed please let me know. The following sections are designed to be read in order. More advanced readers may want to skip the first three or four sections however as they cover very basic concepts.

Special Thanks

Many people assisted with the creation of this guide. Isaac Dealy, creator of Tapestry was, as always, a great sounding board. Dave Watts of Figleaf and Adam Cameron went above and beyond in reviewing the material and ended up teaching me a few new things in the process. Matthew Woodward, Sean A Corfield, Andy J, Erik Allen, Brian Simmons, and Matt Robertson provided invaluable comments and proofreading.

742 Current Sessions; Time: 10:19:48 08-09-2010; Tick: 141