php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7591 continue doesn't work inside switch statement
Submitted: 2000-11-02 09:57 UTC Modified: 2000-11-05 11:40 UTC
From: joel at azursoft dot fr Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.3pl1 OS: linux glibc 2.1
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: joel at azursoft dot fr
New email:
PHP Version: OS:

 

 [2000-11-02 09:57 UTC] joel at azursoft dot fr
When placed inside a switch statement located inside a for
loop, the continue doesn't work as usual in C:

the following code display the following output:

<?
	for ( $i=0; $i<10; $i++ ) {
		switch ( $i ) {
		case 5:	continue;
		default:
			echo "$i<br>";
		}
		echo "Should be printed only if i != 5 and now i == $i<br>";
	}
?>

//output:

0
Should be printed only if i != 5 and now i == 0
1
Should be printed only if i != 5 and now i == 1
2
Should be printed only if i != 5 and now i == 2
3
Should be printed only if i != 5 and now i == 3
4
Should be printed only if i != 5 and now i == 4
Should be printed only if i != 5 and now i == 5
6
Should be printed only if i != 5 and now i == 6
7
Should be printed only if i != 5 and now i == 7
8
Should be printed only if i != 5 and now i == 8
9
Should be printed only if i != 5 and now i == 9

// End of output

The line :
Should be printed only if i != 5 and now i == 5
should not appear

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-05 11:40 UTC] stas@php.net
continue relates to switch as a looping structure (just as break does), so what it does is to continue switch. Use "continue 2;" to do what you want.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Jul 15 12:00:01 2026 UTC