
44
Chapter 2: Elements of CFML
Constants
The value of a
constant
does not change during program execution. Constants are simple scalar
values that you can use within expressions and functions, such as “Robert Trent Jones” and
123.45. Constants can be integers, real numbers, time and date values, Boolean values, or text
strings. ColdFusion does not allow you to give names to constants.
Variables
Variables
are the most frequently used operands in ColdFusion expressions. Variable values can be
set and reset, and can be passed as attributes to CFML tags. Variables can be passed as parameters
to functions, and can replace most constants.
ColdFusion has a number of built-in variables that provide information about the server and are
returned by ColdFusion tags. For a list of the ColdFusion built-in variables, see
Chapter 1,
“Reserved Words and Variables,”
in
CFML Reference
.
The following two characteristics classify a variable:
•
The
scope
of the variable, which indicates where the information is available and how long the
variable persists
•
The
data type
of the variable’s value, which indicates the kind of information a variable
represents, such as number, string, or date
The following section lists and briefly describes the variable scopes.
“Data types” on page 45
lists
data types (which also apply to constant values). For detailed information on ColdFusion
variables, including data types, scopes, and their use, see
Chapter 3, “Using ColdFusion
Variables,” on page 53
.
Variable scopes
The following table describes ColdFusion variable scopes:
Scope Description
Variables
(local)
The default scope for variables of any type that are created with the
cfset
and
cfparam
tags. A local variable is available only on the page on which it is created and
any included pages.
Form
The variables passed from a form page to its action page as the result of submitting
the form.
URL
The parameters passed to the current page in the URL that is used to call it.
Attributes
The values passed by a calling page to a custom tag in the custom tag’s attributes.
Used only in custom tag pages.
Caller
A reference, available in a custom tag, to the Variables scope of the page that calls
the tag. Used only in custom tag pages.
ThisTag
Variables that are specific to a custom tag, including built-in variables that provide
information about the tag. Used only in custom tag pages. A nested custom tag can
use the
cfassociate
tag to return values to the calling tag’s ThisTag scope.
Request
Variables that are available to all pages, including custom tags and nested custom
tags, that are processed in response to an HTTP request. Used to hold data that
must be available for the duration of one HTTP request.
Summary of Contents for ColdFusion MX
Page 1: ...Developing ColdFusion MX Applications...
Page 22: ...22 Contents...
Page 38: ......
Page 52: ...52 Chapter 2 Elements of CFML...
Page 162: ......
Page 218: ...218 Chapter 10 Writing and Calling User Defined Functions...
Page 250: ...250 Chapter 11 Building and Using ColdFusion Components...
Page 264: ...264 Chapter 12 Building Custom CFXAPI Tags...
Page 266: ......
Page 314: ...314 Chapter 14 Handling Errors...
Page 344: ...344 Chapter 15 Using Persistent Data and Locking...
Page 349: ...About user security 349...
Page 357: ...Security scenarios 357...
Page 370: ...370 Chapter 16 Securing Applications...
Page 388: ...388 Chapter 17 Developing Globalized Applications...
Page 408: ...408 Chapter 18 Debugging and Troubleshooting Applications...
Page 410: ......
Page 426: ...426 Chapter 19 Introduction to Databases and SQL...
Page 476: ...476 Chapter 22 Using Query of Queries...
Page 534: ...534 Chapter 24 Building a Search Interface...
Page 556: ...556 Chapter 25 Using Verity Search Expressions...
Page 558: ......
Page 582: ...582 Chapter 26 Retrieving and Formatting Data...
Page 668: ......
Page 734: ...734 Chapter 32 Using Web Services...
Page 760: ...760 Chapter 33 Integrating J2EE and Java Elements in CFML Applications...
Page 786: ...786 Chapter 34 Integrating COM and CORBA Objects in CFML Applications...
Page 788: ......