CFML notes
A few language details I have been writing down while I figure out CFML.
This is not a language reference. The official Lucee and Adobe documentation already does that. These are simply the parts that have helped me relate CFML to the PHP and MySQL work I already know.
Tags and script can live together
The older examples I first looked at were very tag-heavy. One of the first things I learned is that CFML can mix that style with CFScript.
<cfset pageTitle = "Hello from CFML">
<cfscript>
count = 3;
message = "This came from CFScript";
</cfscript>
<cfoutput>
<h2>#encodeForHTML(pageTitle)#</h2>
<p>#encodeForHTML(message)# (#count#)</p>
</cfoutput>
Scopes are everywhere
CFML has named scopes such as url, form, session, application, request, variables, and arguments. Being explicit about them makes the code easier for me to follow while I am learning what lives where.
<cfscript> search = structKeyExists(form, "search") ? trim(form.search) : ""; page = structKeyExists(url, "page") ? val(url.page) : 1; </cfscript>
Arrays and structures feel familiar
Array and structure literals are straightforward enough that basic data handling started to feel familiar pretty quickly.
<cfscript>
servers = ["web01", "db01", "backup01"];
settings = {
environment: "lab",
debug: true
};
</cfscript>
Queries are one of the parts I am still getting used to
Database access feels different from the way I normally work in PHP. A datasource can be configured for the CFML engine, and query results are something the language knows how to work with directly.
<cfquery name="customers" datasource="cf_learning">
SELECT id, name
FROM customers
ORDER BY name
</cfquery>
<cfoutput query="customers">
#encodeForHTML(name)#<br>
</cfoutput>
There are script-oriented ways to work with queries too. I am still experimenting with both styles.
CFCs
A .cfc file is a ColdFusion Component. I am only starting to use them, but thinking of them as a place for reusable application logic has made them easier for me to understand.
That is about as far as I want this page to go
I do not want this to turn back into a giant tag reference or an accidental CFML textbook. I would rather add things here as I actually run into them.
For the broader experiment, see Modern CFML and Lucee.
