What is the difference between Switch and IF?

前端 未结 5 586
终归单人心
终归单人心 2021-01-13 10:30

I know this may be simple question but want to know every ones opinion on this.

what is the difference between switch and IF function in PHP?? What I can see is wher

5条回答
  •  感动是毒
    2021-01-13 11:08

    No, you are right.
    There are not much difference between these statements.
    You may use one you like.

    Just bear in mind that if you have to use more than 3-4 consecutive conditions - that means you most likely have design faults.

    Usually you can substitute such a statement with a loop or with more clear application design.

提交回复
热议问题