User Guide

14 Chapter 2 Writing Your First ColdFusion Application
you can write:
Id like to talk to someone in #Variables.Department#.
Some variable scopes, such as the local scope, do not require the scope identifier
prefix, while others do. However, it is good programming practice to use prefixes for
most or all scopes. This helps to better identify each variables use and can prevent
multiple uses of the same name. This book uses the scope prefix for all variables
except for local variables.
The following table lists some of the more common types of variable scopes and the
prefixes that you use to identify the variables. Other chapters in this book discuss
additional scope types. The CFML Reference has a complete list of scope types, their
identifiers, and how they are used.
Using the pound sign (#)
You surround a ColdFusion variable or function with pound signs (#) to tell the
ColdFusion Server that it is not plain text. You only need to use pound signs in
limited circumstances, particularly in the cfoutput and cfquery tag blocks. You do
not need to use pound signs when you create a variable, assign it a value, or use it in
a ColdFusion expression or as a parameter in a ColdFusion function.
Note
Remember that ColdFusion cannot interpret anything, including variables, that is
not inside a ColdFusion tag or tag block.
The following table illustrates the basic use of pound signs. For a detailed description
of the use of pound signs, see CFML Reference.
Scope type Prefix Description
Local (or
Variables)
Variables Variables created using cfset or cfparam, with or without
specifying the scope prefix. You must define the variable
on the current page or a page you include using
cfinclude.
Form Form Data entered in tags in an HTML form or ColdFusion
cfform tag block and processed on an action page.
URL URL Variables passed to a page as URL query string
parameters.
CFML code Results
cfset Department="Sales">
The variable named Department is created
and the value is set to Sales.
<cfoutput>
Id like to talk to someone in
Department.
</cfoutput>
ColdFusion does not treat Department as a
variable because it is not surrounded by
pound signs. The HTML page displays:
Id like to talk to someone in Department.