3v4l.org

run code in 300+ PHP versions simultaneously
<?php function printer() { for ($i = 0; $i < 10; $i++) { $string = (yield $i); var_dump($string); } } $printer = printer(); echo 'current: '; var_dump($printer->current()); $printer->send('Hello world!'); echo 'current: '; var_dump($printer->current()); $printer->next(); echo 'current: '; var_dump($printer->current()); $printer->send('Bye world!'); echo 'current: '; var_dump($printer->current());

preferences:
70.08 ms | 404 KiB | 5 Q