3v4l.org

run code in 500+ PHP versions simultaneously
<?php foreach(new class( new Handler(15, \FizzBuzz::class, new Handler(3, \Fizz::class, new Handler(5, \Buzz::class, fn($n) => (string)$n, ))), range(1, 100)) implements IteratorAggregate{ function __construct(private $handler, private $input){} function getIterator(): Generator { return (function() { foreach($this->input as $n) yield ($this->handler)($n) ?><?php })()?><?php } } as $fizzbuzz) echo $fizzbuzz,PHP_EOL?><?php final class Handler{ function __construct(private $n, private $s, private $succ){} function isMatched(int $n):bool{return$n%$this->n===0?><?php} function __invoke(int $n){return $this->isMatched($n) ? $this : ($this->succ)($n)?><?php } function __toString(){ return $this->s?><?php }}
Output for git.master_jit, git.master
Fatal error: Uncaught Error: Class "Handler" not found in /in/SLqeg:2 Stack trace: #0 {main} thrown in /in/SLqeg on line 2
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:
40.71 ms | 660 KiB | 3 Q