I was in the process of writing a switch case when I read on the PHP site:
Thus, it is important not to forget break statements (even though you may want to avoid supplying them on purpose under certain circumstances).
A switch case without break statements was perfect for what I wanted to do. I want all the cases below the matched one to execute. Why is this wrong, and what is the best way to do it differently?
Is it bad for all languages, or just PHP? Why?
edit: Whether it is or isn’t a problem, is there a way to do the same thing without a switch case?
As it noted – even though you may want to avoid supplying them on purpose under certain circumstances. As long as you know what you are doing, then falling through case is not a problem. Personally, I think that it’s a large reason why using case statements can be so useful (instead of &&’s, but that’s just me).
So the answer is, it’s not bad for any particular language, because you aren’t fighting with the language.