Instead of answering a PHP question, I will answer a bit in general. It does not apply directly to PHP, as it will go through some kind of interpretation.
Many compilers can convert to and from if-elif-elif -... blocks to switch blocks if necessary, and the tests in the elif parts are quite simple (and the rest of the semantics are compatible). For 3-4 tests, it is not necessary to get anything using the conversion table.
The reason is that the predictor branch in the CPU is really good at predicting what is going on. In fact, the only thing that happens is a little higher pressure on the choice of a team, but it is unlikely to be destroying the world.
In your example, however, most compilers recognize that $ var is a constant of 3, and then replaces $ var with 3 in if..elif blocks ... This, in turn, makes the expressions constant, so they add up either to true, either false. All false branches kill the dead code ejector, and the truth test is also eliminated. The case remains when $ var == 3. You cannot rely on PHP, albeit smart. In general, you cannot distribute $ var, but this is possible on some sites.
source share