Question #71   Submitted by Answiki on 06/14/2020 at 06:43:57 PM UTC

How to make strict type comparison in PHP switch...case?

Answer   Submitted by Answiki on 06/14/2020 at 06:48:09 PM UTC

You cannot make strict type comparisons in PHP switch case. In other words, you can't use a === comparison in switch statements as stated in the documentation:


Note:Note that switch/case does loose comparison.


Loose comparison is the opposite of strict comparison.

5 events in history
Question by Answiki 06/14/2020 at 06:49:01 PM
How to use === comparison instead of == in PHP switch...case?
Question by Answiki 06/14/2020 at 06:48:53 PM
How to use === comparison instead of == in PHP switch statements?
Question by Answiki 06/14/2020 at 06:48:30 PM
How to make strict type comparison in PHP switch statements?
Answer by Answiki on 06/14/2020 at 06:48:09 PM

You cannot make strict type comparisons in PHP switch case. In other words, you can't use a === comparison in switch statements as stated in the documentation:


Note:Note that switch/case does loose comparison.


Loose comparison is the opposite of strict comparison.

Question by Answiki 06/14/2020 at 06:43:57 PM
How to make strict type comparison in PHP switch...case?
# ID Query URL Count

Icons proudly provided by Friconix.