Doc #69099 [NEW]: incomplete/ambiguous statement about continue
| From: | teo8976 at gmail dot com | Date: | Sat, 21 Feb 2015 19:04:02 +0000 |
| Subject: | Doc #69099 [NEW]: incomplete/ambiguous statement about continue | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-11964@lists.php.net to get a copy of this message | ||
From: teo8976 at gmail dot com
Operating system: all
PHP version: Irrelevant
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:incomplete/ambiguous statement about continue
Description:
------------
---
From manual page: http://www.php.net/control-structures.continue
---
"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.
--
Edit bug report at https://bugs.php.net/bug.php?id=69099&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69099&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69099&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69099&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69099&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69099&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69099&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69099&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69099&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69099&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69099&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69099&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69099&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69099&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69099&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69099&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69099&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69099&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69099&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69099&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69099&r=mysqlcfg