note 106335 added to control-structures.break

From: Date: Fri, 28 Oct 2011 15:43:10 +0000
Subject: note 106335 added to control-structures.break
Groups: php.notes 
Request: Send a blank email to php-notes+get-184200@lists.php.net to get a copy of this message
In response to Miguel Cruz 15-Apr-2009 07:37: as with PHP 5.3.1 using "0" as optional argument sadly behaves the same way as not using an argument (or using "1"). So you're not able to do something like this: <?php // Something which either returns either 0 or 1, where // 0 = nothing has been done, so we want to continue to loop // 1 = succeeded, no need to run the loop till the end, let's exit it function foo() { return 'some'== 'expression'? 1: 0; } // Some loop which we might want to leave for( $iLoop= 0; $iLoop< 10; $iLoop++ ) { // Sadly this will ALWAYS exit the loop :( // If "break 0;" would do nothing it would be more versatile for usage break foo(); } ?> ---- Server IP: 217.160.235.204 Probable Submitter: 85.180.167.230 ---- Manual Page -- http://www.php.net/manual/en/control-structures.break.php Edit -- https://master.php.net/note/edit/106335 Del: integrated -- https://master.php.net/note/delete/106335/integrated Del: useless -- https://master.php.net/note/delete/106335/useless Del: bad code -- https://master.php.net/note/delete/106335/bad+code Del: spam -- https://master.php.net/note/delete/106335/spam Del: non-english -- https://master.php.net/note/delete/106335/non-english Del: in docs -- https://master.php.net/note/delete/106335/in+docs Del: other reasons-- https://master.php.net/note/delete/106335 Reject -- https://master.php.net/note/reject/106335 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#184200) next »