The <cffunction> Tag

ColdFusion Components usually contain one or more functions (often called methods; the two terms are effectively interchangeable). A function is simply a block of code that performs an operation, and usually returns results. Each function is defined using a tag named <cffunction> and terminated with the matching closing tag </cffunction>.

<cffunction> takes a series of attributes, but only two are really important:

  • name is the name of the function (it must be unique within the CFC; the same method name may be used in two different CFCs but not twice in the same CFC).

  • returntype is the type of the results that will be returned (string, date, array, query, etc.).

Listing 11.3 is intro.cfc again, but this time we’ve introduced ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.