Switch case with three parameters?

前端 未结 7 1556
野趣味
野趣味 2020-12-17 20:49

Is it possible to use three parameters in switch-case, like this:

switch($var1, $var2, $var3){
    case true, false, false:
        echo \"Hello\";
        b         


        
7条回答
  •  一向
    一向 (楼主)
    2020-12-17 21:30

    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;
    }
    

提交回复
热议问题