(PHP 4, PHP 5, PHP 7)
elseif锟斤拷锟酵达拷锟斤拷锟狡帮拷示锟斤拷一锟斤拷锟斤拷锟斤拷
if 锟斤拷 else 锟斤拷锟斤拷稀锟斤拷锟�
else 一锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷 if
锟斤拷洌拷锟斤拷锟斤拷锟皆拷锟斤拷锟� if 锟斤拷锟绞街滴� FALSE
时执锟叫诧拷同锟斤拷洹o拷锟斤拷呛锟� else 锟斤拷一锟斤拷锟斤拷锟角o拷锟斤拷锟斤拷锟斤拷
elseif 锟斤拷锟斤拷锟斤拷锟斤拷锟绞街滴� TRUE
时执锟斤拷锟斤拷洹o拷锟斤拷锟斤拷锟斤拷麓锟斤拷虢拷锟斤拷锟斤拷锟斤拷锟斤拷直锟斤拷锟绞�
a is bigger than b锟斤拷a
equal to b 锟斤拷锟斤拷
a is smaller than b锟斤拷
<?php
if ($a > $b) {
echo "a is bigger than b";
} elseif ($a == $b) {
echo "a is equal to b";
} else {
echo "a is smaller than b";
}
?>
锟斤拷同一锟斤拷 if 锟斤拷锟斤拷锌锟斤拷锟斤拷卸锟斤拷
elseif 锟斤拷锟街o拷锟斤拷锟叫碉拷一锟斤拷锟斤拷锟绞街滴� TRUE
锟斤拷锟斤拷锟斤拷械幕锟斤拷锟斤拷锟�
elseif 锟斤拷锟街斤拷锟斤拷执锟叫★拷锟斤拷
PHP 锟叫o拷也锟斤拷锟斤拷写锟斤拷"else
if"锟斤拷锟斤拷锟斤拷锟斤拷锟绞o拷锟斤拷锟斤拷锟斤拷"elseif"锟斤拷一锟斤拷锟斤拷锟绞o拷锟斤拷锟斤拷为锟斤拷全一锟斤拷锟斤拷锟戒法锟斤拷锟斤拷锟侥猴拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟较�
C 锟斤拷锟皆的伙拷锟斤拷锟斤拷之锟斤拷为锟斤拷同锟斤拷锟斤拷锟斤拷锟角碉拷锟斤拷锟斤拷锟斤拷锟竭伙拷锟斤拷锟斤拷锟饺伙拷锟斤拷锟斤拷锟轿拷锟�
elseif 锟斤拷锟斤拷锟斤拷锟斤拷之前锟斤拷 if 锟斤拷锟斤拷锟斤拷之前
elseif 锟侥憋拷锟绞街滴� FALSE
锟斤拷锟斤拷锟揭碉拷前锟斤拷
elseif 锟斤拷锟绞街滴� TRUE
时执锟叫★拷
Note: 锟斤拷锟斤拷要注锟斤拷锟斤拷锟� elseif 锟斤拷 else if 只锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷使锟矫伙拷锟斤拷锟脚碉拷锟斤拷锟斤拷虏锟斤拷锟轿拷锟斤拷锟饺拷锟酵拷锟斤拷锟斤拷锟斤拷冒锟斤拷锟斤拷锟斤拷锟斤拷 if/elseif 锟斤拷锟斤拷锟斤拷锟角就诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟绞碉拷 else if锟斤拷锟斤拷锟斤拷 PHP 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟�
<?php
/* 锟斤拷锟斤拷确锟斤拷使锟矫凤拷锟斤拷锟斤拷 */
if($a > $b):
echo $a." is greater than ".$b;
else if($a == $b): // 锟斤拷锟睫凤拷锟斤拷锟斤拷
echo "The above line causes a parse error.";
endif;
/* 锟斤拷确锟斤拷使锟矫凤拷锟斤拷锟斤拷 */
if($a > $b):
echo $a." is greater than ".$b;
elseif($a == $b): // 注锟斤拷使锟斤拷锟斤拷一锟斤拷锟斤拷锟绞碉拷 elseif
echo $a." equals ".$b;
else:
echo $a." is neither greater than or equal to ".$b;
endif;
?>