switch(var){case v1:express;case v2:express;default:express;}。例如:
//根據變量i的不同值控制不同的輸出for(i=0;i<5;i++){switch(i){case 0:echo("it is zero");case 1:echo("it is 1");default:echo(i);}}//根據字符串str的值輸出不同結果var str = "hello";for(i=0;i<5;i++){str += i;switch(str){case "hello0":echo(str);case "hello01":echo("it is" + str);default:echo(str.length);}}