For more information and examples on using number signs in expressions, see ColdFusion MX
Developer's Guide.
Specifying quotation marks around values
When you assign literal values to variables, you must surround the literal value with single- or
double-quotation marks. ColdFusion interprets the content between the quotation marks as a
literal value and assigns that value to the variable; for example:
<cfset my_first_name = "Kaleigh">
<cfset my_last_name = "Smith">
<cfset my_age = 5>
ColdFusion instantiates the variable
is assigned to the variable
When referencing a variable by its name, you do not surround the name with quotation marks. In
the following example, when you concatenate literal text and variables using the & operator, you
don't surround the variable references with quotation marks:
<cfset the_string = "My name is " & variables.my_first_name &
" and my age is " & variables.my_age>
is literal text, and you, therefore, surround it with quotation marks. The variable
My name is
references
variables.my_first_name
marks. ColdFusion uses the values of the referenced variables (
assigning the value to the variable
To display quotation marks on a page as literal characters, you must use two consecutive
quotation marks; for example:
<cfset mystring = "We all shouted ""Happy Birthday"" when he entered the
room.">
<cfoutput>
#mystring#
</cfoutput>
The result is the following output:
We all shouted "Happy Birthday" when he entered the room.
Specifying operators in expressions
In ColdFusion, you use operators to test conditions; for example, you use the
for equality. When you use operators in expressions, you must only use supported logical
operators that ColdFusion can interpret properly. For example, if you use the greater than
operator (>) or the less than operator (<), ColdFusion interprets them as the start or end of a tag
rather than as an operator.
my_first_name
and
my_last_name
5
and
variables.my_age
.
the_string
to the string literal
is assigned to age.
are not surrounded by quotation
Kaleigh
Working with CFML expressions
. Further,
Kaleigh
Smith
and
, respectively) when
5
operator to test
IS
25
Need help?
Do you have a question about the COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION MX and is the answer not in the manual?
Questions and answers