PHP switch case default

前端 未结 4 994

Will the default of a switch statement get evaluated if there\'s a matching case before it?

ex:

switch ($x) {
  case ($x > 5): print \"foo\";
  ca         


        
4条回答
  •  难免孤独
    2020-12-11 04:26

    It would have been easier to try it yourself.

    But anyway, if you don't use break in a case, all the the cases following it will be executed (including the default).

提交回复
热议问题