3v4l.org

run code in 300+ PHP versions simultaneously
<?php function generator(): iterable { $count = -1; while (true) { echo 'Stopping: ', $count, \PHP_EOL; yield ++$count; echo 'Resuming: ', $count, \PHP_EOL; } } function limit(\Iterator $inner, int $count) { if (1 > $count) return; $inner->rewind(); while ($inner->valid()) { if (!$count--) { return; } yield $inner->key() => $inner->current(); $inner->next(); } } echo "Construct:\n"; $i = limit(generator(), 3); echo "Rewind:\n"; $i->rewind(); echo "\n1st iteration\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current value: ", $i->current(), "\n"; $i->next(); echo "\n2nd iteration\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current value: ", $i->current(), "\n"; $i->next(); echo "\n3rd iteration\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current value: ", $i->current(), "\n"; $i->next(); echo "\n4th iteration\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current value: ", $i->current(), "\n"; $i->next(); echo "\n5th iteration\n"; echo $i->valid() ? "Valid\n" : "Not valid\n"; echo "Current value: ", $i->current(), "\n"; $i->next();
Output for git.master, git.master_jit, rfc.property-hooks
Construct: Rewind: Stopping: -1 1st iteration Valid Current value: 0 Resuming: 0 Stopping: 0 2nd iteration Valid Current value: 1 Resuming: 1 Stopping: 1 3rd iteration Valid Current value: 2 Resuming: 2 Stopping: 2 4th iteration Not valid Current value: 5th iteration Not valid Current value:

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
25.12 ms | 402 KiB | 8 Q