DEV Community

Discussion on: Be careful about the switch statement in PHP

Collapse
 
bellinivitor profile image
Vitor Bellini Federle

Isn't it better to use an ENUM?

Collapse
 
klnjmm profile image
Jimmy Klein

The example is here to show the difference between loose comparaison (switch) and strict comparaison.

Enum or not, you will probably encountered a switch case in your code, and the goal here is to warn people of the loose comparaison.

Collapse
 
bellinivitor profile image
Vitor Bellini Federle

Hmmm, this part is well explained, great job!