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
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: 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

Pull Requests

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 Dec 21 18:01:29 2024 UTC