3v4l.org

run code in 300+ PHP versions simultaneously
<?php var_dump(ini_get('memory_limit')); echo "\n"; $shallowFiberFactoryFiber = new Fiber(function(): void { $fiberNumber = 0; while (true) { $res = new Fiber(function (\Closure $fx) use (&$fiberNumber): void { $res = $fx($fiberNumber++); Fiber::suspend($res); }); Fiber::suspend($res); } }); $shallowFiberFactoryFx = function () use ($shallowFiberFactoryFiber): \Fiber { return !$shallowFiberFactoryFiber->isStarted() ? $shallowFiberFactoryFiber->start() : $shallowFiberFactoryFiber->resume(); }; $i = 0; $fx = function (int $fiberNumber) use ($shallowFiberFactoryFx): void { $res = array_map(function ($str) use ($shallowFiberFactoryFx, $fiberNumber) { global $i, $fx; $i++; // log/debug execution if (($i % 1_000) === 0) { var_dump($i . ' at fiber: ' . $fiberNumber); } // terminating cond if ($i > 50_000) { return 'finished at fiber: ' . $fiberNumber; } // recurse - every 2k reentry unroll the machine stack using Fiber return ($i % 2_000) === 0 ? $shallowFiberFactoryFx()->start($fx)[0] : $fx($fiberNumber); }, ['x']); Fiber::suspend($res); }; $res = $shallowFiberFactoryFx()->start($fx); echo "\n"; print_r($res);
Output for git.master, rfc.property-hooks
string(3) "64M" string(16) "1000 at fiber: 0" string(16) "2000 at fiber: 0" string(16) "3000 at fiber: 1" string(16) "4000 at fiber: 1" string(16) "5000 at fiber: 2" string(16) "6000 at fiber: 2" string(16) "7000 at fiber: 3" string(16) "8000 at fiber: 3" string(16) "9000 at fiber: 4" string(17) "10000 at fiber: 4" Fatal error: Out of memory (allocated 18874368 bytes) (tried to allocate 16384 bytes) in /in/0Jjrr on line 27 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for git.master_jit
string(3) "64M" string(16) "1000 at fiber: 0" string(16) "2000 at fiber: 0" string(16) "3000 at fiber: 1" string(16) "4000 at fiber: 1" Fatal error: Out of memory (allocated 8388608 bytes) (tried to allocate 20480 bytes) in /in/0Jjrr on line 26 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
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:
28.86 ms | 407 KiB | 5 Q