The variable will be the same throughout your part of the code: in PHP, there is no "per block" variable scope.
So, if $something is 1 or 2 , so you enter one of the case into a switch , your code will output 1 or 2.
On the other hand, if $something not 1 and 2 (for example, if it is treated as 0 , which is the case with the code you sent, since it is not initialized by anything), you will not enter any of the case blocks; and the code will output 0 .
source share