Creates simple and compound conditional statements in CFML. Tests an expression, variable, function return value, or string. Used, optionally, with the cfelse and cfelseif tags.



<cfif expression> 
HTML and CFML tags <cfelseif expression> 
HTML and CFML tags 
HTML and CFML tags 

See also


If the value of the expression in the cfif tag is true, ColdFusion processes all the code that follows, up to any cfelseif or cfelse tag, and then skips to the cfif end tag. Otherwise, ColdFusion does not process the code that immediately follows the cfif tag, and continues processing at any cfelseif or cfelse tag, or with the code that follows the cfif end tag.
When testing the return value of a function that returns a Boolean, you do not have to define the True condition explicitly. This example uses the IsArray function:

<cfif IsArray(myarray)>

If successful, IsArray evaluates to yes, the string equivalent of the Boolean True. This is preferred over explicitly defining the True condition this way:

<cfif IsArray(myarray) IS True>

This tag requires an end tag.



<cfset value = 10> 
<cfif value GT 20> 
    <cfoutput>Greater than 10</cfoutput> 
<cfelseif value EQ 8> 
    <cfoutput>Equal to 8</cfoutput> 




Get help faster and easier

New user?