Skip navigation.
Home

Creating your first Coldfusion Component Step 1

Coldfusion Components (CFC)

(1) All CFC's have the .cfc extension

Coldfusion Components usually contain one or more functions/methods.

Function: a block of code that performs an operation & usually returns a result. Tag <cffunction> </cffunction>

This tag has several attributes BUT only 2 are really important.

(1) name: your name of the function. This has to be unique for your component. You can reuse the name in a diffrent component.

(2) returntype: basically the results you would like returned. String, Date, Array, Query etc...

EXAMPLE 1

<cfcomponent>

<cffunction name="today" returntype="date">

</cffunction>

<!-- Get Tomamrows Date -->

<cffunction name="tommarow" returntype="date">

</cffunction>

<!-- Get yesterday date-->

<cffunction name="yesterday" returntype="date">

</cffunction>

</cfcomponent>