Use case
to run some code when a variable has a specified value:
<?php
$a = 3;
switch($a) {
case 1:
echo "One";
break;
case 2:
echo "Two";
break;
case 3:
echo "Three";
break;
}
?>
Try it Yourself »
The case
keyword is used to jump to a line of code when an expression has a specific value in a switch
conditional.
The switch
keyword.
Read more about the switch conditional in our PHP switch Statement Tutorial.
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!