Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 76

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Note: You do not need to use number signs when you use the cfset tag to assign one variable's value to another value. For
example, the following tag assigns the value of the
.
oldVar>
Using number signs in tag bodies
You can place variables or functions freely inside the bodies of the following tags by enclosing each variable or
expression with number signs:
cfoutput
cfquery
cfmail
For example:
<cfoutput>
Value is #Form.MyTextField#
</cfoutput>
<cfoutput>
The name is #FirstName# #LastName#.
</cfoutput>
<cfoutput>
The value of Cos(0) is #Cos(0)#
</cfoutput>
If you omit the number signs, the text, rather than the value, appears in the output generated by the
statement.
Two expressions inside number signs can be adjacent to one another, as in the following example:
<cfoutput>
"Mo" and "nk" is #Left("Moon", 2)##Mid("Monkey", 3, 2)#
</cfoutput>
This code displays the following text:
"Mo" and "nk" is Monk
ColdFusion does not interpret the double number sign as an escaped # character.
Using number signs in strings
You can place variables or functions freely inside strings by enclosing each variable or expression with number signs;
for example:
<cfset TheString = "Value is #Form.MyTextField#">
<cfset TheString = "The name is #FirstName# #LastName#.">
<cfset TheString = "Cos(0) is #Cos(0)#">
ColdFusion automatically replaces the text with the value of the variable or the value returned by the function. For
example, the following pairs of
<cfset TheString = "Hello, #FirstName#!">
<cfset TheString = "Hello, " & FirstName & "!">
If number signs are omitted inside the string, the text, rather than the value, appears in the string. For example, the
following pairs of
statements produce the same result:
cfset
variable to the new variable,
oldVar
statements produce the same result:
cfset
Last updated 1/20/2012
:
newVar
<cfset newVar =
cfoutput
71

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents