Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function ff($e){
- for($i=0;$i<$e;++$i){
- yield $i;
- }
- }
- $iter=ff(11);
- foreach($iter as $v)..
- while($iter->valid()){
- echo $iter->current();
- $iter->next();
- }
- ...
- function logger($fileName) {
- $fileHandle = fopen($fileName, 'a');
- while (true) {
- fwrite($fileHandle, yield . "\n");
- }
- }
- $logger = logger(__DIR__ . '/log');
- $logger->send('Foo');
- $logger->send('Bar');
- function html($fileName='php://output'){
- $h = fopen($fileName, 'w');
- try {
- fwrite($h,'@start');
- fwrite($h, (yield 'ok'));
- fwrite($h,'@end');
- } finally {
- fclose($h);
- }
- }
- $i=html( );
- $msg=$i->current();
- $i->send($msg.':'. 123);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement