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);}}