Programming instructions
18 Chapter 2 CFML Basics
The DollarFormat function returns a value as a string and formats that value with two
decimal places, thousand separator, and dollar sign. The pounds signs (#) around the
function instruct ColdFusion to evaluate the content between the pound signs and
display the value.
Functions and parentheses
All functions have parentheses, regardless of whether the function acts on data. Consider
the following function:
#Now()#
If you put anything inside the parentheses of the Now() function, an error would occur.
The
Now() function returns an unformatted date and time. However, you can format the
results of this function with other functions, such as the
DateFormat() or
TimeFormat() functions.
Nesting functions
Functions can generate data as well as act on data. Consider the following example:
#DateFormat(Now(), "mm/dd/yyyy")#
In this example, the Now() function generates the date, and then the DateFormat
function formats the date.
Functions and pound signs
You use pound signs (#) with functions to display the results of a function on the page.
Pound signs tell the ColdFusion server to evaluate the content between the pound signs
and display the value, for example:
<cfoutput>
Hello world, <br>
Today’s date is #DateFormat(Now(), "mm/dd/yyyy")#
</cfoutput>
The following figure shows the output of this example: