Any way to break if statement in PHP?

前端 未结 20 2098
無奈伤痛
無奈伤痛 2020-12-02 05:05

Is there any command in PHP to stop executing the current or parent if statement, same as break or break(1) for switch/

20条回答
  •  悲哀的现实
    2020-12-02 05:27

    $a = 1;
    
    switch($a) {
    
      case "1":
    
        if  ($condition1){
          break;
        }
    
        if  ($condition2){
          break;
        }
    
        if  ($condition3){
          break;
        }
    }
    

    In this way I got what I want. I use a switch only has a definite case and then use break in case to choose if condition. The reason why I use the break : condition1 and condition2 may both satisfy, in that situation only condition1 is applied .IF is selective according the order.

提交回复
热议问题