note 68193 added to control-structures.continue

From: Date: Mon, 17 Jul 2006 21:18:40 +0000
Subject: note 68193 added to control-structures.continue
Groups: php.notes 
Request: Send a blank email to php-notes+get-114859@lists.php.net to get a copy of this message
Documentation states: "continue is used within looping structures to skip the rest of the current loop iteration" Current functionality treats switch structures as looping in regards to continue. It has the same effect as break. The following code is an example: <?php for ($i1 = 0; $i1 < 2; $i1++) { // Loop 1. for ($i2 = 0; $i2 < 2; $i2++) { // Loop 2. switch ($i2 % 2) { case 0: continue; break; } print '[' . $i2 . ']<br>'; } print $i1 . '<br>'; } ?> This outputs the following: [0] [1] 0 [0] [1] 1 Switch is documented as a block of if...elseif... statements, so you might expect the following output: [1] 0 [1] 1 This output requires you to either change the switch to an if or use the numerical argument and treat the switch as one loop. ---- Server IP: 216.194.113.175 Probable Submitter: 64.253.100.16 ---- X-Spam-Status: No, hits=3.3 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_MESSAGE autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/control-structures.continue.php Edit -- http://master.php.net/note/edit/68193 Del: integrated -- http://master.php.net/note/delete/68193/integrated Del: useless -- http://master.php.net/note/delete/68193/useless Del: bad code -- http://master.php.net/note/delete/68193/bad+code Del: spam -- http://master.php.net/note/delete/68193/spam Del: non-english -- http://master.php.net/note/delete/68193/non-english Del: in docs -- http://master.php.net/note/delete/68193/in+docs Del: other reasons-- http://master.php.net/note/delete/68193 Reject -- http://master.php.net/note/reject/68193 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114859) next »