?
本文檔使用 PHP中文網(wǎng)手冊 發(fā)布
JScript? | 語言參考 |
根據(jù)表達(dá)式的值,有條件地執(zhí)行一組語句。
@if (
? condition1)
???text1[@elif (
? condition2)
???text2]
[@else
???text3]
@end
condition1, condition2
可選項(xiàng)??梢詮?qiáng)制轉(zhuǎn)換為 Boolean 表達(dá)式的表達(dá)式。
text1
可選項(xiàng)。condition1 是 true 時(shí)要解析的文本。
text2
可選項(xiàng)。condition1 是 false 且 condition2 是 true 時(shí)要解析的文本。
text3
可選項(xiàng)。condition1 和 condition2 都是 false 時(shí)要解析的文本。
在書寫 @if 語句時(shí),不必將每個(gè)子句放到不同的行??梢允褂枚鄠€(gè) @elif 子句。但是,所有 @elif 子句必須在 @else 子句之前出現(xiàn)。
通常使用 @if 語句來決定應(yīng)當(dāng)使用若干選項(xiàng)中的哪個(gè)選項(xiàng)來進(jìn)行文本輸出。例如:
alert(@if (@_win32) "using Windows NT or Windows 95" @else "using Windows 3.1" @end)
版本 3
條件編譯 | 條件編譯變量 | @cc_on 語句 | @set 語句