View comments | RSS feed
Contents > Getting Started Building ColdFusion MX Applications > CFML Basics > Working with CFML expressions > Building expressions Specifying quotation marks around values PreviousNext

Specifying quotation marks around values

When assigning literal values to variables, you must surround the literal value with double quotation marks or single 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 my_first_name to the string literal Kaleigh. Further, Smith is assigned to the variable my_last_name and 5 is assigned to age.

When referencing a variable by its name, you do not surround the name with quotation marks; for example:

<cfset the_string = "My name is " & variables.my_first_name & 
" and my age is " & variables.my_age>

My name is is literal text and, you therefore, surround it with quotation marks. The variable references variables.my_first_name and variables.my_age are not surrounded by quotation marks. ColdFusion uses the values of the referenced variables (Kaleigh and 5, respectively) when assigning the value to the variable the_string.

To display quotation marks on a page as literal characters, you must double the 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.


Contents > Getting Started Building ColdFusion MX Applications > CFML Basics > Working with CFML expressions > Building expressions Specifying quotation marks around values PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


joonstar said on Sep 16, 2003 at 1:01 AM :
Then, what is "&" surrounding ' varialbe.my_name', and in front of 'variable.my_age'?
jrunrandy said on Sep 18, 2003 at 10:40 AM :
The & is the concatenation operator. See http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/elemen11.htm for more information.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/cfml_b18.htm