If Statements

If statements are a fundamental part of most development languages. Though the syntax varies from one language to the next, the basic concepts and options are the same. If statements are used to create conditions that are evaluated, enabling you to perform actions based on the result.

The conditions passed to if statements always evaluate to TRUE or FALSE, and any condition that can be expressed as a TRUE / FALSE (or YES / NO) question is valid. Here are some examples of valid conditions:

  • Is today Monday?

  • Does variable FirstName exist?

  • Were any rows retrieved from a database?

  • Does variable one equal variable two?

  • Is a specific word in a sentence?

More complex conditions (multiple conditions) are allowed, too:

  • Is today Sunday or Saturday? ...

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.