这是我的
PHP代码:
switch ($i) { case 0: echo '$i is 0.'; break; case 1: case 2: case 3: case 4: case 5: echo '$i is somewhere between 1 and 5.'; break; case 6: case 7: echo '$i is either 6 or 7.'; default: echo "I don't know how much \$i is."; } ?>
现在,我如何使用替代语法而不是大括号语法来创建代码?
在这种情况下,我甚至不觉得有使用Switch的要求,最好使用if或if else语句.
原文链接:https://www.f2er.com/php/134210.htmlif($i==0){ echo "value is 0"; } else if($i>0 && $i<6){ echo "value is between 1 and 5"; }else if($i>5 && $i<8){ echo "value is 6 or 7"; }else{ echo "unknown value"; }