• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 3. Variables and Functions

Lesson 3. Variables and Functions

When you develop a Web site with ColdFusion, two of the most important tools that you will use are variables and functions. You will probably spend more time on tasks that involve working with variables and functions than with any other features (other than database interactivity).

Variables are what you use when you want to store information to use later. Think of them as containers that hold a piece of information, such as a name, a date, or a price. When you want to use the piece of information, you take it out of the container. The variable, or container, has a specific name, and when you want to use the information in the variable you reference it by that name.

You will be using functions and variables in just about every ColdFusion page you build. The ones used in this example are the now() and dateformat() functions as well as a simple variable.

Functions offer a wide variety of built-in abilities that can affect your templates in numerous ways. Each function performs a specific task and has an expected result. Many functions are built in to the ColdFusion Server, although you can also create your own.

In this lesson and the following lessons, we'll work on tasks related to the design, use, and maintenance of a Web site for a fictitious company called The Wireless Agent. Some of the activities will be related to the user experience, and some to the administrator; all involve using ColdFusion to handle different tasks. For users, you will set up functions that allow them to search for products and display the results of their search, as well as display details about those products. For administrators, you will create pages that allow them to add, update, and delete products from the site, keeping the product information fresh and up to date.


In this lesson, you will:

  • Learn what variables and functions are

  • Create and display a date variable

  • Pass a date variable between two templates

  • Use a function to format a date


This lesson takes approximately 1 hour to complete.


Starting Files:



Completed Files:





Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint