Understanding Functions

To understand how functions work, it's helpful to think of them as real-time manipulators of data. I say real-time because the manipulation occurs at the moment a user views a template page including your expertly coded function.

Functions use the format SomeFunction(SomeVariable), where the variable you want to manipulate is placed between the parentheses. When you use functions within <CFOUTPUT> tags, you enclose the entire function string in hash marks (rather than enclosing the variable), like this:

#SomeFunction(SomeVariable)#

ColdFusion reads the entire hash-delimited string, performs whatever manipulations the function requires, and returns the results as output.

Note

When functions are used as part of a ColdFusion ...

Get Sams Teach Yourself ColdFusion® in 21 Days now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.