php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #26209 'continue' feature or bug?
Submitted: 2003-11-11 16:23 UTC Modified: 2003-11-14 11:32 UTC
From: marrtins at hackers dot lv Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.3.3 OS: w2k,sp4
Private report: No CVE-ID: None
 [2003-11-11 16:23 UTC] marrtins at hackers dot lv
Description:
------------
strnge things happen (at least undocumented) with continue control structure when using continue with and w/o semicolon

in example below continue w/o semi reproduces 2
with semi as expected 0,1,3 and 4

Reproduce code:
---------------
<?
  for($r = 0; $r < 5; ++$r) {
    if($r == 2)
      continue
    print "$r\n";
  }
?>

Expected result:
----------------
0
1
3
4

Actual result:
--------------
2

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-11-12 08:14 UTC] didou@php.net
From the documentation :

"continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip to the end of."

and we see that :

  var_dump(print "$r\n"); // int(1)

you see your problem here ? Anyway, the documentation should have a warning to avoid confusion.

didou
 [2003-11-14 11:32 UTC] didou@php.net
This have been fixed in CVS.

I have added an example of what we shouldn't do when using continue, guess who wrote it ? ;)

http://news.php.net/article.php?group=php.doc&article=969356927
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Sep 18 17:01:27 2024 UTC