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 and can contain only letters, numbers, and the underscore character. Variable names can’t contain spaces. For example,
Test,MyVariable,My_variable,MyVariable1, andMyDescriptive_var2are all valid ColdFusion variables, while4C,MyVariable,Phone#, andA/Paren’t.Avoid using variable names that may be reserved words in SQL, such as
Time,Date, andOrder.Avoid using variable names that are the same as ColdFusion variable scopes:
Application,Attribute,Caller,CGI,Client,Cookie,Form,Variable,Request,Server,Session,URL, andQuery.Avoid choosing variable names that end in
_date,_eurodate,_float,_integer,_range,_required, or_time, as these are reserved suffixes for server-side form validation variables and can cause naming conflicts.ColdFusion variable names aren’t case-sensitive. ...
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.
Read now
Unlock full access