Any way to break if statement in PHP?

前端 未结 20 2101
無奈伤痛
無奈伤痛 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-02 05:34

    There exist command: goto

    if(smth) {
       .....
       .....
       .....
       .....
       .....
       goto Area1;
       .....
       .....
    
    
    }
    
    
    
    Area1:
    ....your code here....
    

    However, remember goto is not a recommended practice, because it makes the code to be formatted unusually.

提交回复
热议问题