|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #69099 incomplete/ambiguous statement about continue
Submitted: 2015-02-21 19:04 UTC Modified: 2015-03-25 20:30 UTC
From: teo8976 at gmail dot com Assigned: aharvey (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: all
Private report: No CVE-ID: None
 [2015-02-21 19:04 UTC] teo8976 at gmail dot com
From manual page:

"Note: Note that in PHP the switch statement is considered a looping structure for the purposes of continue."

It is completely unclear what that means, if it wasn't thanks to a user's comment. It does ring a bell that you have to be careful when using a continue statement inside a switch statement (where in most cases it won't do what you expect) but it doesn't explain even vaguely what the behavior is and hence what you are supposed to do to avoid unexpected behavior.

One may expect that "continue" in the context of a switch statement may jump to the next case, while it seems that it will effectively be equivalent to a break inside a switch.

The note should be expanded to be clearer, and a couple of examples should be added:
- one without any loop structure outside the switch statement containing the continue statement; with no argument to continue. Which would be only a theoretical example where "continue" would be effectively equivalent to "break"
- one with a switch inside a for/while loop, first without any argument passed to continue, where the result is to only break the switch statement (most probably unwanted), and then with "continue 1" to obtain the (most probably wanted) effect of continuing the outside for loop.


doc-bug-69099.patch (last revision 2015-03-18 18:16 UTC by patrick dot schwisow at gmail dot com)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-22 00:29 UTC]
-Status: Open +Status: Feedback
 [2015-02-22 00:29 UTC]
Did you know you can submit patches to the documentation yourself? Since you have ideas on how to improve it, go ahead and suggest them: click Edit in the top right, log in (or stay anonymous), and edit the XML source of the documentation. When you're done, save and submit the change as a patch.

I'd suggest revising that paragraph a little to help with the language, and focusing on demonstrating the behavior of continue using an example or two.

If you do that then you can Close this ticket. Otherwise move this back to Open and someone else can.
 [2015-02-22 00:44 UTC] teo8976 at gmail dot com
> Did you know you can submit patches to the documentation yourself? 

Yeah, I knew.
The problem is I'm not good at writing docs.

I thought reporting the issue would be better than nothing.
 [2015-02-22 00:46 UTC] teo8976 at gmail dot com
-Status: Feedback +Status: Open
 [2015-02-22 00:46 UTC] teo8976 at gmail dot com
trying to set this to Open
 [2015-03-18 13:33 UTC] patrick dot schwisow at gmail dot com
The attached patch clarifies the note.
 [2015-03-25 20:30 UTC]
Automatic comment from SVN on behalf of aharvey
Log: Clarify what happens when continue is used in a switch statement.

Fixes doc bug #69099 (incomplete/ambiguous statement about continue); patch by
Patrick Schwisow.
 [2015-03-25 20:30 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: aharvey
 [2015-03-25 20:30 UTC]
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Thanks to Patrick Schwisow for the patch.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun May 09 08:01:23 2021 UTC