20
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:
Содержание COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Страница 1: ...Getting Started Building ColdFusion MX Applications...
Страница 6: ...6 Contents...
Страница 10: ......
Страница 30: ...30 Chapter 2 CFML Basics...
Страница 36: ...36 Chapter 3 Database Fundamentals...
Страница 48: ......
Страница 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Страница 134: ...134 Index...