php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #747 continue semantics incorrect within switch statement?
Submitted: 1998-09-14 19:20 UTC Modified: 1998-09-15 01:26 UTC
From: rziegler at idea-net dot com Assigned:
Status: Closed Package: Parser error
PHP Version: 3.0.3 OS: Solaris 2.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: rziegler at idea-net dot com
New email:
PHP Version: OS:

 

 [1998-09-14 19:20 UTC] rziegler at idea-net dot com
I'm not sure that this is a bug, or a feature, but either way it
should probably be documented:

The following code segment does not work as a "C" programmer would
assume:

  for ($i=1; $i<=10; $i++)
  {
    switch($i)
    {
      case 1: case 3: case 5: case 7: case 9:
        break;
      case 2: case 4: case 6: case 8: case 10:
        continue;
    }
    print("$i is Odd\n");
  }

If you change the "continue" to be a "continue 2", the code
works correctly.  Because a continue (again, in C) does not apply to switch statement (only whiles and fors), this does not seem correct.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1998-09-15 01:26 UTC] zeev
This is a documented difference between PHP and C.  Switch
statements are, for all practical purposes in PHP, considered
as loops.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 01:01:31 2024 UTC