PHP是一种松散类型的语言。当与大小写0匹配时,字符串与最接近的整数匹配。
假设我们有以下开关表达式-
switch ("match")
现在,我们将匹配情况0-
case 0: echo " 0 with match"; break;
我们还将匹配非零情况-
case "match": echo "match successful"; break;
<!DOCTYPE html> <html> <body> <?php switch ("match") { case 0: echo " 0 with match"; break; case "match": echo "match successful"; break; } ?> </body> </html>
输出结果
0 with match