The PHP is a loosely typed language. When you match with case 0 the string matches with closest integer.
Let’s say we have the following switch expression −
switch ("match")
Now, we will match with case 0 −
case 0: echo " 0 with match"; break;
We will also match for non-zero case −
case "match": echo "match successful"; break;
Example
<!DOCTYPE html> <html> <body> <?php switch ("match") { case 0: echo " 0 with match"; break; case "match": echo "match successful"; break; } ?> </body> </html>
Output
0 with match