3v4l.org

run code in 300+ 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 }}

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.0.00.0120.00616.70
7.4.130.0150.00916.57
7.4.120.0130.00516.46
7.4.110.0090.00916.53
7.4.100.0030.01316.28
7.4.90.0060.01016.36
7.4.80.0060.01016.48
7.4.70.0060.01016.29
7.4.60.0110.00516.34
7.4.50.0060.01116.39
7.4.40.0050.01116.44
7.4.30.0170.00016.48
7.4.20.0040.01316.28
7.4.10.0190.00816.43
7.4.00.0150.00416.52
7.3.250.0180.00016.38
7.3.240.0140.00616.07
7.3.230.0130.01016.36
7.3.220.0100.00616.26
7.3.210.0060.01016.25
7.3.200.0060.00916.25
7.3.190.0060.00916.14
7.3.180.0160.00316.21
7.3.170.0100.00616.24
7.3.160.0040.01316.14
7.3.150.0040.01216.39
7.3.140.0060.01316.22
7.3.130.0140.00316.23
7.3.120.0170.00016.32
7.3.110.0120.00616.40
7.3.100.0130.00316.27
7.3.90.0110.00716.19
7.3.80.0160.00316.18
7.3.70.0030.01516.12
7.3.60.0110.00716.08
7.3.50.0090.00916.14
7.3.40.0100.00716.19
7.3.30.0160.00016.27
7.3.20.0130.00516.22
7.3.10.0120.00616.29
7.3.00.0090.00916.16

preferences:
144.93 ms | 939 KiB | 8 Q