php中switch语句case后表达式写法记录一
可作等级评价:
$var = 95; switch(true){ case $var < 100; $level = 1; break; case $var < 95; $level = 2; break; default : $level=9; break; }
手册案例:(充许case后使用分号)
<?php switch($beer) { case 'tuborg'; case 'carlsberg'; case 'heineken'; echo 'Good choice'; break; default; echo 'Please make a new selection...'; break; } ?>