Edit

Operators in CFML

This is an incomplete / work in progress guide to operators in CFML.

Equality

EQ ScriptTags

IS ScriptTags

== ScriptTagsCF 8+

if (animal == "cow") {
    return "mooo!";
}

The EQ, IS, and == operators are case insensitive, so "PETE" IS "pete" evaluates to true.

Inequality

NEQ ScriptTags

IS NOT ScriptTags

!= ScriptTagsCF 8+

if (true != false) {
    return "sanity";
}

Negation

NOT ScriptTags

! ScriptTagsCF 8+

if ( !isLocalHost(cgi.remote_addr) ) {
    throw("sorry localhost only");
}

Comparison

GREATER THAN ScriptTagsGT ScriptTags> ScriptTags

GREATER THAN OR EQUAL TO ScriptTagsGTE ScriptTagsGE ScriptTags>= ScriptTags

LESS THAN ScriptTagsLT ScriptTags< ScriptTags

LESS THAN OR EQUAL TO ScriptTagsLTE ScriptTagsLE ScriptTags<= ScriptTags

CONTAINS ScriptTagsDOES NOT CONTAIN ScriptTags

Lucee supports the following shorthand for the CONTAINS and DOES NOT CONTAIN operators.

CT ScriptTagsNCT ScriptTags

Concatenation

& ScriptTags

name = name & " Jr.";

&= ScriptTagsCF 8+

name &= " Jr.";

Both code examples are equivalent.

Compatibility Notes

The operators ==, !=, <, <=, >, and >= do not work in tags such as cfif or cfset in Adobe ColdFusion (as of Version 2016). However the ==, !=, <, and <= operators work from tags on Lucee, but > and >= do not.

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub