3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function out() { while ($v = yield) { print "Received $v.\n"; yield "($v)"; } print "Close\n"; } $out = out(); print "Current: " . $out->current() . "\n"; print "Current: " . $out->current() . "\n"; $out->send('A'); print "Current: " . $out->current() . "\n"; print "Current: " . $out->current() . "\n"; $out->send('B'); print "Current: " . $out->current() . "\n"; print "Current: " . $out->current() . "\n"; $out->send(NULL); print "Current: " . $out->current() . "\n"; print "Current: " . $out->current() . "\n"; $out->send('C'); print "Current: " . $out->current() . "\n"; print "Current: " . $out->current() . "\n";
based on bJMik
Output for 5.6.0 - 7.3.0alpha1
Current: Current: Received A. Current: (A) Current: (A) Current: Current: Close Current: Current: Current: Current: