PHP elseif 关键字
实例
如果第一个条件不满足,则测试第二个条件:
  <?php
if(5 < 3) {
echo "Five is less than three";
} else if(5 > 4) {
echo "Five is greater than four";
}
?>
亲自试一试 »
if(5 < 3) {
echo "Five is less than three";
} else if(5 > 4) {
echo "Five is greater than four";
}
?>
定义和用法
elseif 关键字测试一个新条件,如果之前的条件 if 或 elseif 语句。 这相当于将 if 语句放在 else 块中。
以下代码块是等价的:
  <?php
if (...) {
some code here
} elseif (...) {
some code here
}
?>
if (...) {
some code here
} elseif (...) {
some code here
}
?>
  <?php
if (...) {
some code here
} else{
if (...) {
some code here
}
}
?>
if (...) {
some code here
} else{
if (...) {
some code here
}
}
?>
相关页面
if关键字。
在我们的 PHP if else 教程中了解有关 if...elseif...else 条件的更多信息。
