switch statement without break

后端 未结 6 1503
粉色の甜心
粉色の甜心 2021-01-17 21:35

How come a case option in a switch statement that does not contain a break automatically forwards to a next case without check?

try {
    switch($param) {
          


        
6条回答
  •  情歌与酒
    2021-01-17 22:30

    I don't really see what you want.

    1. If you want to run the default stuff in all cases, just put it after the switch.
    2. If you want to run the default stuff only in the "created" case and in the default case, swap the position of the "created" and "Creator" sections and put a break after the first.
    3. If you want that code to only run if Creator or created matches, then get rid of the switch statement and use an if/else OR use a flag and a following if statement.

    All the tools are there.

提交回复
热议问题