The switch construct is always a bit of a risk when you do not specify a break, as execution will just continue to the next cases without testing those conditions.
As stated in the docs, I emphasise in bold:
It is important to understand how the switch statement is executed in order to avoid mistakes. The switch statement executes line by line (actually, statement by statement). In the beginning, no code is executed. Only when a case statement is found with a value that matches the value of the switch expression does PHP begin to execute the statements. PHP continues to execute the statements until the end of the switch block, or the first time it sees a break statement. If you don't write a break statement at the end of a case's statement list, PHP will go on executing the statements of the following case.
So, to be clear: PHP does not verify case conditions any more once it has started executing statements inside a case. Without a break, it will just continue with the statements of the next cases without verifying the case conditions. And so it goes from case to case, executing all statements until it finds a break or the end of the switch.
So the following code:
switch (1) {
case 1:
echo "one ";
case 2:
echo "two ";
case "hello":
echo "hello ";
}
will output:
one two hello
PHP finds the first case condition to be true and starts executing statements without evaluating any other case conditions.
This may be very counter-intuitive, and also makes the code less readable. It is best practice to put a break at the end of each case to avoid any misunderstanding.