Coldfusion Control Structures: Which IF does the else go to?
In Java, the else statement goes to the closetest If statement.
so if you have a nested if statement:
if (expression) {
if(secExpression) {
}
else {
// goes with second expression
}
}
The else goes with the second if nested inside.
Where does the else go to in the Coldfusion control structure?
开发者_StackOverflow中文版<cfif expression>
<cfif secExpression>
</cfif>
<cfelse>
</cfif>
The nested-tag syntax makes it unambiguous: The <cfelse>
has to be inside of the <cfif ...> ... </cfif>
tag, so in your example the <cfelse>
can only be related to the outer <cfif>
.
精彩评论