Skip to content

Instantly share code, notes, and snippets.

@mkusher
Created July 22, 2014 12:40
Show Gist options
  • Save mkusher/1dc68a1baf23aed95cb4 to your computer and use it in GitHub Desktop.
Save mkusher/1dc68a1baf23aed95cb4 to your computer and use it in GitHub Desktop.
<?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