Catalog / CFML Cheatsheet
CFML Cheatsheet
A quick reference guide to ColdFusion Markup Language (CFML), covering syntax, data types, control structures, functions, and more.
CFML Basics
Syntax Fundamentals
Tags |
CFML uses tags (similar to HTML) to define code blocks. Example:
|
Variables |
Variables are dynamically typed and declared using Example:
|
Comments |
Single-line and multi-line comments are supported. Example:
|
Output |
The Example:
|
CFScript |
CFScript allows you to write CFML code using a scripting syntax (similar to JavaScript). Example:
|
Data Types |
CFML supports various data types including String, Numeric, Boolean, Date, Array, and Struct. Example:
|
Variable Scopes
Application |
Variables available throughout the entire application. Example:
|
Session |
Variables specific to a user’s session. Example:
|
Request |
Variables available during a single request. Example:
|
Server |
Variables available throughout the entire server. Example:
|
Client |
Variables stored on the client’s machine (usually via cookies). Example:
|
Local |
Variables available within a specific function or component. Example:
|
Control Structures
Conditional Statements
|
Basic conditional statement. Example:
|
|
Used for multiple conditions. Example:
|
|
Switch statement for multiple cases. Example:
|
Looping Structures
|
Numeric loop. Example:
|
|
Looping through an array. Example:
|
|
Looping through a query result. Example:
|
|
Conditional loop. Example:
|
|
Looping through a list. Example:
|
Exception Handling
|
Exception handling block. Example:
|
Functions
String Functions
|
Converts a string to uppercase. Example:
|
|
Converts a string to lowercase. Example:
|
|
Returns the leftmost characters of a string. Example:
|
|
Returns the rightmost characters of a string. Example:
|
|
Extracts a substring from a string. Example:
|
|
Returns the length of a string. Example:
|
|
Returns the starting position of a substring within a string. Example:
|
|
Replaces occurrences of a substring within a string. Example:
|
Date and Time Functions
|
Returns the current date and time. Example:
|
|
Formats a date according to a specified mask. Example:
|
|
Formats a time according to a specified mask. Example:
|
|
Adds a specified interval to a date. Example:
|
|
Calculates the difference between two dates. Example:
|
|
Creates a date object. Example:
|
Array Functions
|
Creates a new array. Example:
|
|
Appends an element to an array. Example:
|
|
Returns the length of an array. Example:
|
|
Returns the average of the elements in an array. Example:
|
|
Returns the minimum value in an array. Example:
|
|
Returns the maximum value in an array. Example:
|
Components and Objects
Component Definition
|
Defines a CFML component (CFC). Example:
|
|
Defines a function within a component. Example:
|
|
Specifies the access level of a function (public, private, remote). Example:
|
|
Specifies the return type of a function. Example:
|
|
Defines an argument for a function. Example:
|
Object Creation and Usage
|
Creates an instance of a CFML component. Example:
|
Using dot notation |
Accessing properties and methods of an object. Example:
|