Created
July 22, 2014 12:40
-
-
Save mkusher/1dc68a1baf23aed95cb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file is part of the php4fun package. | |
* | |
* (c) Aleh Kashnikau <[email protected]> | |
* | |
* Created: 22/07/2014 3:31 PM | |
*/ | |
class YieldTest{ | |
public static $flag = true; | |
public static function generate(){ | |
$i=0; | |
while(self::$flag){ | |
yield $i++; | |
} | |
} | |
} | |
$generator = YieldTest::generate(); | |
foreach($generator AS $value){ | |
var_dump($value); | |
if($value > 5) | |
YieldTest::$flag = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment