note 102608 added to control-structures.goto

From: Date: Thu, 24 Feb 2011 12:11:46 +0000
Subject: note 102608 added to control-structures.goto
Groups: php.notes 
Request: Send a blank email to php-notes+get-177278@lists.php.net to get a copy of this message
tweston at coldsteelstudios dot com, your "goto loop" is not while replacement, but "do ... while" replacement. In short - while structure can be not executed if when starting loop condition is not met, while your's "goto loop" executes once and then test the condition. In other words: <?php goto_loop: $i++; if( $i < 100 ) goto goto_loop; ?> is identical to <?php do{ i++; } while( $i < 100 ); ?> but isn't identical to <?php while( $i < 100 ){ $i++; } ?> When $i is set to 1000 before those loops, the first two will end with $i = 1001, while the third will end with $i = 1000. ---- Server IP: 195.114.0.19 Probable Submitter: 77.253.221.74 ---- Manual Page -- http://www.php.net/manual/en/control-structures.goto.php Edit -- https://master.php.net/note/edit/102608 Del: integrated -- https://master.php.net/note/delete/102608/integrated Del: useless -- https://master.php.net/note/delete/102608/useless Del: bad code -- https://master.php.net/note/delete/102608/bad+code Del: spam -- https://master.php.net/note/delete/102608/spam Del: non-english -- https://master.php.net/note/delete/102608/non-english Del: in docs -- https://master.php.net/note/delete/102608/in+docs Del: other reasons-- https://master.php.net/note/delete/102608 Reject -- https://master.php.net/note/reject/102608 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#177278) next »