Variables - MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Develop Manual

Developing web applications with coldfusion
Table of Contents

Advertisement

Chapter 2: Writing Your First ColdFusion Application

Variables

A Web application page is different from a static Web page because it can publish data
dynamically. This involves creating, manipulating, and outputting variables.
A variable stores data that can be used in applications. As with other programming
languages, you'll set variables in ColdFusion to store data that you want to access later.
And you'll reference a range of variables to perform different types of application
processing.
There are a variety of variable types that you can create and reference in your
ColdFusion applications. Also, ColdFusion variables are typeless, which means that
you don't need to define whether or not the variable value is numeric, text, or time-
date. See the CFML Language Reference for a complete list of variable types
The primary differences between variable types are where they exist, how long they
exist, and where their values are stored. These considerations are referred to as a
variable's scope.
You will learn more about scope as needed throughout this book.
For example, you would store a user's preferences in a variable in order to use that data
to customize the page that's returned to the browser.
You don't use pound signs when you create the variable. However, when you want to
display the value that a variable is set to, enclose the variable name in pound signs (#).
The following table illustrates the use of pound signs and variable names.
CFML Code
<CFSET Department="Sales">
<CFOUTPUT>
I'd like to talk to someone in
Department.
</CFOUTPUT>
<CFOUTPUT>
I'd like to talk to someone in
#Department#.
</CFOUTPUT>
Results
The variable named Department is created
and the value is set to Sales.
ColdFusion doesn't treat Department as a
variable because it isn't surrounded by
pound signs. The HTML page will display:
I'd like to talk to someone in Department.
ColdFusion replaces the variable Department
with its value. The HTML page will display:
I'd like to talk to someone in Sales.
13

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-DEVELOPING WEB and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Coldfusion 4.5

Table of Contents