这是我在PHP和MySQL Web开发看到的switch的分支语句,它在default也加上了break,一般不用加也行啊。我已经看到过很多次这样的写法,为什么会这样写呢?求大神普及下。
switch($find) {
case "a" :
echo '<p>Regular customer.</p>';
break;
case "b" :
echo '<p>Customer referred by TV advert.</p>';
break;
case "c" :
echo '<p>Customer referred by phone directory</p>';
break;
case "d" :
echo '<p>Customer referred by word of mouth.</p>';
break;
default :
echo '<p>We do not know how this customer found us.</p>';
break;
}