Language Reference |
Conditionally executes a group of statements, depending on the value of an expression.
The @if statement syntax has these parts:
Part Description condition1, condition2 An expression that can be coerced into a Boolean expression. text1 Text to be parsed if condition1 is true. text2 Text to be parsed if condition1 is false and condition2 is true. text3 Text to be parsed if both condition1 and condition2 are false.
When you write an @if statement, you don't have to place each clause on a separate line. You can use multiple @elif clauses, however, all @elif clauses must come before an @else clause.
You commonly use the @if statement to determine which text among several options should be used for text output. For example:alert(@if (@_win32) "using Windows NT or Windows 95" @else "using Windows 3.1" @end)