note 106335 deleted from control-structures.break by danbrown

From: Date: Fri, 28 Oct 2011 23:32:48 +0000
Subject: note 106335 deleted from control-structures.break by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-184207@lists.php.net to get a copy of this message
Note Submitter: Anonymous ---- 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(); } ?>

« previous php.notes (#184207) next »