What is the difference between Switch and IF?

前端 未结 5 587
终归单人心
终归单人心 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 10:42

    The Switch Case Statement is an alternative to the if/else statement, which does almost the same thing. The Switch Case Statement executes line by line or statement by statement in other words, and once PHP finds a case statement that evaluates to true, it executes the code corresponding to that case statement. The fundamental difference between if/else and switch statements is that the if/else statement selects the execution of the statements based upon the evaluation of the expression in if statements, but the Switch Case Statement selects the execution of the statement often based on a keyboard command.

提交回复
热议问题