3v4l.org

run code in 300+ PHP versions simultaneously
<?php // thanks to metaultralurker on reddit for inspiration function call(callable $fn) { return $fn(); } function map(callable $fn, \Traversable $data) { return call(function () use ($fn, $data) { foreach ($data as $v) { yield $fn($v); } }); } function filter(callable $fn, \Traversable $data) { return call(function () use ($fn, $data) { foreach ($data as $v) { if ($fn($v)) { yield $v; } } }); } $isNotZ = function ($x) { return $x !== 'Z'; }; $data = filter($isNotZ, map('strtoupper', call(function () { foreach (range('a', 'z') as $char) { yield $char; } }))); var_dump($data->current()); $data->next(); var_dump($data->current()); $data->next(); var_dump(iterator_to_array($data));
Output for git.master_jit, git.master, rfc.property-hooks
string(1) "A" string(1) "B" Fatal error: Uncaught Exception: Cannot rewind a generator that was already run in /in/MSoU3:44 Stack trace: #0 /in/MSoU3(44): iterator_to_array(Object(Generator)) #1 {main} thrown in /in/MSoU3 on line 44
Process exited with code 255.

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:
41.48 ms | 401 KiB | 8 Q