control structures break


breakPHP ManualPrevChapter 11. Control StructuresNextbreak break ends execution of the current if, for, while, or switch structure. break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of. 1  2 $i = 0; 3 while ($i < 10) { 4  if ($arr[$i] == "stop") { 5  break; /* You could also write 'break 1;' here. */ 6  } 7  $i++; 8 } 9  10 /* Using the optional argument. */ 11  12 $i = 0; 13 while ( ++$i ) { 14  switch ( $i ) { 15  case 5: 16  echo "At 5<br>\n"; 17  break 1; /* Exit only the switch. */ 18  case 10: 19  echo "At 10; quitting<br>\n"; 20  break 2; /* Exit the switch and the while. */ 21  default: 22  break; 23  } 24 } 25  PrevHomeNextforeachUpcontinue

Wyszukiwarka

Podobne podstrony:
control structures break
control structures break
control structures continue
control structures for
control structures while
control structures elseif
control structures switch
control structures foreach
control structures
control structures switch
control structures declare
control structures foreach
control structures
control structures do while
control structures continue
control structures alternative syntax
control structures else

więcej podobnych podstron