Your variable $t has an integer value of 0 . Using the switch you tell PHP to compare it first with the value of 'add' (string). PHP does this by converting 'add' to an integer and due to the conversion rules, the result is 0 .
As a result, the first branch is taken - which may be surprising, but it was also expected.
You will see the expected behavior if you did
$t = "0";
Now both $t and 'add' are strings, so magic conversion does not occur, and of course they compare unequal ones.
source share