[ÇÔ¼ö] break - ÇöÀçÀÇ ¹Ýº¹¹®À» ºüÁ®³ª°£´Ù |
|
|
![](icon/private_name/1.gif) |
13³â Àü |
break
break´Â ÇöÀç for, foreach while, do..while ¶Ç´Â switchÀýÀÇ ¼öÇàÀ» ¸ØÃá´Ù.
break´Â ¼ýÀÚ ÀÎÀÚ ¿É¼ÇÀ» Çã¿ëÇÔÀ¸·Î½á ³»Æ÷µÈ ±¸¹®±¸Á¶ÀÇ ±íÀ̸¦ Ç¥½ÃÇÏ°í °Å±â¼ ºüÁ®³ª¿Ã¼ö ÀÖ°Ô ÇØÁØ´Ù.
<?php
$arr = array('one', 'two', 'three', 'four', 'stop', 'five');
while (list (, $val) = each ($arr)) {
if ($val == 'stop') {
break; /* ¿©±â¼´Â 'break 1;'À¸·Î ½½ ¼ö ÀÖ½À´Ï´Ù. */
}
echo "$val<br />\n";
}
/* ¿É¼Ç ÀÎÀÚ »ç¿ëÇϱâ. */
$i = 0;
while (++$i) {
switch ($i) {
case 5:
echo "At 5<br />\n";
break 1; /* switch¸¸ ºüÁ®³ª°©´Ï´Ù. */
case 10:
echo "At 10; quitting<br />\n";
break 2; /* switch¿Í whileÀ» ºüÁ®³ª°©´Ï´Ù. */
default:
break;
}
}
?> |
|
̵̧ : 457 |
̵̧
¸ñ·Ï
|
|