3v4l.org

run code in 500+ PHP versions simultaneously
<?php class It implements \IteratorAggregate { public function getIterator(): \Generator { yield 'foo'; Fiber::suspend(); var_dump("not executed"); } } function f() { var_dump(yield from new It()); } $iterable = f(); $fiber = new Fiber(function () use ($iterable) { var_dump($iterable->current()); $iterable->next(); var_dump("not executed"); }); $ref = $fiber; $fiber->start(); gc_collect_cycles(); ?>
Output for 8.2.23 - 8.2.30, 8.3.11 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
string(3) "foo"
Output for 8.1.0 - 8.1.34, 8.2.0 - 8.2.22, 8.3.0 - 8.3.10
string(3) "foo"
Process exited with code 139.

preferences:
62.62 ms | 974 KiB | 4 Q