PHP 4.0 Bug #8768 Updated: 'continue' inside of 'switch' statement acts like 'break' instead of 'continue'

From: Date: Tue, 06 Mar 2001 13:03:27 +0000
Subject: PHP 4.0 Bug #8768 Updated: 'continue' inside of 'switch' statement acts like 'break' instead of 'continue'
Groups: php.dev 
Request: Send a blank email to php-dev+get-48032@lists.php.net to get a copy of this message
ID: 8768 Updated by: stas Reported By: godai@neomueller.org Old-Status: Open Status: Closed Bug Type: Scripting Engine problem Assigned To: Comments: switch is a looping structure in PHP, just like for, but one-time. Use "continue 2;" if you want to continue the outer loop. Previous Comments: --------------------------------------------------------------------------- [2001-01-17 16:50:40] godai@neomueller.org When a continue is used inside of a switch statement (inside a loop), it does not jump to the top of the next loop iteration, but instead jumps out of the switch statement and proceeds to execute the code following the switch. The following code snippet should give a good example: <?php for( $i = 0; $i < 10; $i++ ) { switch( $i ) { case 5: continue; default: $garbage = 0; // do something unimportant } echo "$i<BR>"; } ?> The output *should* be the numbers 0 to 4 & 6 to 9 listed down the screen, skipping 5. Instead, 5 appears in the list making it a complete 0 to 9. --------------------------------------------------------------------------- ATTENTION! Do NOT reply to this email! To reply, use the web interface found at http://bugs.php.net/?id=8768&edit=2

« previous php.dev (#48032) next »