MACROMEDIA COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION MX Getting Started page 22

Building coldfusion mx applications
Table of Contents

Advertisement

In the following examples, the variables are assigned a string literal value. All string literal values
are surrounded by double quotation marks.
<cfset my_first_name = "Kaleigh">
<cfset my_last_name = "Smith">
In the next example, ColdFusion uses the values of the
variables to set the value for the
(
) string operator joins the variables, and the space surrounded by double quotation marks (
&
adds a space between the variables.
<cfset my_first_name = "Kaleigh">
<cfset my_last_name = "Smith">
<cfset my_full_name = variables.my_first_name & " " & variables.my_last_name>
Tip: String values assigned to a variable must be enclosed in single (') or double (") quotation marks.
Numeric or Boolean values assigned to a variable do not require single or double quotation marks.
So far all the variable examples shown have been about local variables. Local variables are variables
that you can use only on the current ColdFusion page. As shown in the previous example, a
Variables prefix was used to reference an existing variable on the page. Using a prefix when
referencing a variable is important because ColdFusion supports many types of variables. The
syntax for referencing a local variable is as follows:
variables.variablename
Because ColdFusion lets you use the same name with variables of more than one type,
ColdFusion relies on scope referencing. In scope referencing, you preface the variable's name with
the scope when you refer to that variable.
Other variables and their scope
ColdFusion supports many types of variables. Each type has it own scope, or where it can be
referenced, and its own way of referencing that variable type. The following table identifies some
of the more common types of variables and their prefixes:
Scope
variables
(local variable)
Form
URL
Query
You will use these other types of variables in Part II of this book. For additional information
about variables, see CFML Reference.
22
Chapter 2: CFML Basics
my_full_name
Prefix
Description
Variables
Variables created using
variable on the current page or on a page that you include using
cfinclude
Form
Data entered in tags in an HTML form or ColdFusion form and
processed on the action page.
URL
Variables passed to a page as URL string parameters.
QueryName Variables that are named based on the column names that you select
in the database table. The values are created when you execute the
query that selects data from the database.
my_first_name
variable in the last line of code. The ampersand
or
cfset
.
and
my_last_name
. Most often you define the
cfparam
)
" "

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?

This manual is also suitable for:

Coldfusion mx

Table of Contents