带三个参数的开关盒? [英] Switch case with three parameters?
本文介绍了带三个参数的开关盒?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在切换情况下使用三个参数,如下所示:
Is it possible to use three parameters in switch-case, like this:
switch($var1, $var2, $var3){
case true, false, false:
echo "Hello";
break;
}
如果没有,我应该只使用if-else还是有更好的解决方案?
If not, should I just use if-else or is there a better solution?
推荐答案
语法不正确,即使正确,我也不推荐.但是,如果您真的想使用这样的构造,则可以将值放入数组中:
The syntax is not correct and I wouldn't recommend it, even if it was. But if you really want to use a construct like that, you can put your values into an array:
switch (array($var1, $var2, $var3)) {
case array(true, false, false):
echo "hello";
break;
}
这篇关于带三个参数的开关盒?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文