cfdefaultcase

Used only inside the cfswitch tag body. Contains code to
execute when the expression specified in the cfswitch tag does
not match any of the values specified by preceeding cfcase tags.

  <cfdefaultcase>

 cfdefaultcase();

Examples sample code using the cfdefaultcase tag

vegetable = "";
switch(vegetable) {
    case "carrot":
        writeOutput("Carrots are orange.");
        break;
    default:
        writeOutput("You don't have any vegetables!");
        break;
}

Expected Result: You don't have any vegetables!

<cfset vegetable = "" />
<cfswitch expression="#vegetable#">
    <cfcase value="carrot">
        Carrots are orange.
    </cfcase>
    <cfdefaultcase>
        You don't have any vegetables!
    </cfdefaultcase>
</cfswitch>

Expected Result: You don't have any vegetables!


Fork me on GitHub