Basic If Statements

ColdFusion if statements are created using the <cfif> tag. <cfif> takes no attributes; instead, it takes a condition. For example, the following <cfif> statement checks to see whether a variable named FirstName contains the value Ben:

<cfif FirstName IS "Ben">

The keyword IS is an operator used to test for equality. Other operators are supported, too, as listed in Table 9.1.

Table 9.1. CFML Evaluation Operators
OperatorShortcutDescription
EQUALIS, EQTests for equality
NOT EQUALIS NOT, NEQTests for nonequality
GREATER THANGTTests for greater than
GREATER THAN OR EQUAL TOGTETests for greater than or equal to
LESS THANLTTests for less than
LESS THAN OR EQUAL TOLTETests for less than or equal to
CONTAINS Tests whether a value is contained ...

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.