From 752196dc5a1baec2bdfc0b24bf829634498c3491 Mon Sep 17 00:00:00 2001 From: Rasmus Lerdorf Date: Tue, 27 May 2003 14:21:55 +0000 Subject: [PATCH] Document the fact that continue applies to switch git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@128912 c90b9560-bf6c-de11-be94-00142212c4b1 --- language/control-structures.xml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/language/control-structures.xml b/language/control-structures.xml index 91bd297bbc..54839edd68 100644 --- a/language/control-structures.xml +++ b/language/control-structures.xml @@ -1,5 +1,5 @@ - + Control Structures @@ -679,6 +679,14 @@ while (++$i) { skip the rest of the current loop iteration and continue execution at the beginning of the next iteration. + + + Note that in PHP the + switch statement is + considered a looping structure for the purposes of + continue. + + continue accepts an optional numeric argument which tells it how many levels of enclosing loops it should skip @@ -724,6 +732,15 @@ while ($i++ < 5) { on which value it equals to. This is exactly what the switch statement is for. + + + Note that unlike some other languages, the + continue statement + applies to switch and acts similar to break. If you + have a switch inside a loop and wish to continue to the next iteration of + the outer loop, use continue 2. + + The following two examples are two different ways to write the same thing, one using a series of if