User Guide

Table Of Contents
About scopes 69
Using scopes
The following sections provide details on how you can create and use variables in different scopes.
Evaluating unscoped variables
If you use a variable name without a scope prefix, ColdFusion checks the scopes in the following
order to find the variable:
1.
Function local (UDFs and CFCs only)
2.
Arguments
3.
Variables (local scope)
4.
CGI
5.
Cffile
6.
URL
7.
Form
8.
Cookie
9.
Client
Because ColdFusion must search for variables when you do not specify the scope, you can
improve performance by specifying the scope for all variables.
To access variables in all other scopes, you must prefix the variable name with the scope identifier.
Scopes and CFX tags
ColdFusion scopes do not apply to ColdFusion Extension (CFX) tags, custom tags that you write
in a programming language such as C++ or Java. The ColdFusion page that calls a CFX tag must
use tag attributes to pass data to the CFX tag. The CFX tag must use the Java Request and
Response interfaces or the C++ Request class to get and return data.
This Yes Within a ColdFusion
component or the body of a
user-defined function that was
created using the
cffunction
tag and put in an object,
structure, or scope. In the
containing page, through the
component instance or
containing object.
Within the component or function
by specifying the prefix This when
you create the variable.
In the containing page, by
specifying the component instance
or object that contains the function
as a prefix when you create the
variable.
(function
local, no
prefix)
Prohibited Within the body of a user-
defined function or
ColdFusion component
method, only while the
function executes.
In the function or method definition,
a
var keyword in a cfset tag or a
CFScript
var statement.
Scope
prefix
(type)
Prefix
required to
reference
Where available Created by