Skip to Main Content
Programming ColdFusion MX, 2nd Edition
book

Programming ColdFusion MX, 2nd Edition

by Rob Brooks-Bilson
August 2003
Intermediate to advanced content levelIntermediate to advanced
1140 pages
68h 45m
English
O'Reilly Media, Inc.
Content preview from Programming ColdFusion MX, 2nd Edition

Variables

A variable is a name associated with a data value; it is common to say that a variable stores or contains a value. Variables allow you to store and manipulate data in your applications; they are called variables because the values they represent can change throughout the life of an application. In ColdFusion, you don’t have to explicitly declare your variables, as you do in a language such as C++. Additionally, ColdFusion variables are typeless, meaning that you can assign a value of any datatype (string, numeric, Boolean, object, etc.) to any variable.

Variable Names

The following rules and guidelines apply to variable names in CFML:

  • Variable names must begin with a letter, an underscore, or the Unicode currency symbol ($) and can contain only letters, numbers, underscores, and Unicode currency symbols. Variable names can’t contain spaces. For example, Test, MyVariable, My_variable, MyVariable1, and MyDescriptive_var2 are all valid ColdFusion variables, while 4C, My Variable, Phone#, and A/P aren’t. Note that the addition of the Unicode currency symbol is new in ColdFusion MX.

  • In ColdFusion MX, you cannot use compound variable names delimited with a period, such as Employee.Name. In previous versions of ColdFusion, compound variable names were allowed. In ColdFusion MX, the same syntax is used to automatically create a structure with a specific key and assign a value to that key. For example, <cfset Employee.Name="Pere Money"> creates a structure named Employee ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming ColdFusion

Programming ColdFusion

Rob Brooks-Bilson

Publisher Resources

ISBN: 0596003803Supplemental ContentErrata Page