php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5805 continue does not work properly within a switch
Submitted: 2000-07-27 06:19 UTC Modified: 2000-08-01 16:56 UTC
From: ccurtis at aet-usa dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0.0 OS: Linux (Debian/Unstable)
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: ccurtis at aet-usa dot com
New email:
PHP Version: OS:

 

 [2000-07-27 06:19 UTC] ccurtis at aet-usa dot com
Here is a script:

$n = 3;
while( --$n )
{	echo "Evaluating $n:<br>";
	switch( $n )
	{	case 2:
			continue;
		case 1:
			break;
	}
	echo "fell through<br>";
}

Here is the output:

Evaluating 2:
fell through
Evaluating 1:
fell through

Here is what was expected:

Evaluating 2:
Evaluating 1:
fell through

Changing "continue" to "continue 2" makes it function correctly.  This should not be correct, as a switch is not generally regarded as a looping structure, and PHP does not appear to treat it as one - the continue is simply treated as a break.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-01 16:56 UTC] andi@php.net
In PHP, switch() is similar to a loop scoping wise.
continue and break both have the same effect of ending the switch statement.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Oct 13 20:00:02 2026 UTC