This is an incomplete / work in progress guide to operators in CFML.
EQ
Script ✓ Tags ✓
IS
Script ✓ Tags ✓
==
Script ✓ Tags ✖ CF 8+
if (animal == "cow") {
return "mooo!";
}
The EQ
, IS
, and ==
operators are case insensitive, so "PETE" IS "pete"
evaluates to true
.
NEQ
Script ✓ Tags ✓
IS NOT
Script ✓ Tags ✓
!=
Script ✓ Tags ✖ CF 8+
if (true != false) {
return "sanity";
}
NOT
Script ✓ Tags ✓
!
Script ✓ Tags ✓ CF 8+
if ( !isLocalHost(cgi.remote_addr) ) {
throw("sorry localhost only");
}
GREATER THAN
Script ✓ Tags ✓
GT
Script ✓ Tags ✓
>
Script ✓ Tags ✖
GREATER THAN OR EQUAL TO
Script ✓ Tags ✓
GTE
Script ✓ Tags ✓
GE
Script ✓ Tags ✓
>=
Script ✓ Tags ✖
LESS THAN
Script ✓ Tags ✓
LT
Script ✓ Tags ✓
<
Script ✓ Tags ✖
LESS THAN OR EQUAL TO
Script ✓ Tags ✓
LTE
Script ✓ Tags ✓
LE
Script ✓ Tags ✓
<=
Script ✓ Tags ✖
CONTAINS
Script ✓ Tags ✓
DOES NOT CONTAIN
Script ✓ Tags ✓
Lucee supports the following shorthand for the CONTAINS
and DOES NOT CONTAIN
operators.
CT
Script ✓ Tags ✓
NCT
Script ✓ Tags ✓
&
Script ✓ Tags ✓
name = name & " Jr.";
&=
Script ✓ Tags ✓ CF 8+
name &= " Jr.";
Both code examples are equivalent.
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.