3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Wtf { public function __get($property) { \Fiber::suspend(); echo "hi " . $property . "\n"; } } $fibers[] = new \Fiber(function () { $wtf = new Wtf(); echo $wtf->a; }); $fibers[] = new \Fiber(function () { $wtf = new Wtf(); echo $wtf->b; }); while (\count($fibers) > 0) { foreach ($fibers as $key => $fiber) { if (!$fiber->isStarted()) { $fiber->start(); } elseif ($fiber->isSuspended()) { $fiber->resume(); } // If the Fiber hasn't terminated by this point, move onto the next // placeholder, we'll resume this Fiber again when we get back here. if (!$fiber->isTerminated()) { continue; } unset($fibers[$key]); } }
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
hi a hi b

preferences:
53.05 ms | 834 KiB | 4 Q