S
S
Senseich2018-04-12 21:38:22
PHP
Senseich, 2018-04-12 21:38:22

Why is switch-case compared to if/else?

I understand the question is stupid. But, as far as I understand, this operator only checks for strict equality. After all, you can’t write conditions there more, less, etc. Why is switch-case compared to if/else then?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2018-04-12
@Senseich

switch (true) {
  case ($x > 5):
    ...
    break;
  case ($x < 1):
    ...
    break;
  default:
    ...
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question