我只是想知道是否可以从Switch X中的Case x跳转到Switch Y中的case y。例如,这不正确但是清楚地解释了我想要实现的逻辑:
<?php
Switch ($X){
case '1':
case '2':
case '3':
Goto (Switch ($Y), case y); //Incorrect code, for example only
}
Switch ($Y){
case 'x':
case 'y':
//Do something here
case 'z':
}
?>
如果可以,请回复我需要的正确语法/代码。提前谢谢。
答案 0 :(得分:1)
您可以使用goto运算符作为以下
<?php
switch($X){
case '1':
case '2':
case '3':
goto nextSwitch;
}
nextSwitch:
switch($Y) {
case 'x':
case 'y':
//Do something here
case 'z':
}
?>