3v4l.org

run code in 500+ PHP versions simultaneously
<?php enum FormatOutput: string { case Text = '666777'; case Html = 'html'; } const SOMECONST = 'Const hello'; function SomeFunction() { } $SomeFunctionClosure = function() { }; $SomeFunctionFirstClassCallable = SomeFunction(...); $someFunctionClosureFromCallabe = Closure::fromCallable('SomeFunction'); $arrowFunction = fn($a) => $a; $testcases = [ 666777, '666777', FormatOutput::Text, // For testing purposes: let's see what every type does... SOMECONST, 'abc', -6, 7, -6.7, null, true, false, ['a', 'b', 'c'], [6 => 'six', 7 => 'seven', 67 => 'six seven'], ['a' => 'a', 'b' => 'b', 'c' => 'c', 0 => 'Zero'], function() {}, $SomeFunctionClosure, $SomeFunctionFirstClassCallable, $someFunctionClosureFromCallabe, $arrowFunction, new DateTimeImmutable(), fopen('php://memory', 'w+'), ]; foreach($testcases as $testcase) { echo '--------------[ TESTCASE ]--------------'."\n"; var_dump($testcase); echo "\n"; echo '--- tryFrom()'."\n"; try { $value = FormatOutput::tryFrom($testcase); if ($value !== null) { echo 'Value is '.$value->name.' with value '.$value->value.'.'."\n"; } else { echo 'Value is NULL.'."\n"; } } catch (Throwable $exception) { echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo '--- from()'."\n"; try { $value = FormatOutput::from($testcase); if ($value !== null) { echo 'Value is '.$value->name.' with value '.$value->value.'.'."\n"; } else { echo 'Value is NULL.'."\n"; } } catch (Throwable $exception) { echo $exception::class, ': ', $exception->getMessage(), "\n"; } echo "\n"; echo "\n"; echo "\n"; }

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.5.90.0320.00917.02
8.5.80.0350.00817.00
8.5.70.0330.00816.95
8.5.60.0320.00817.06
8.5.50.0350.00516.91
8.5.40.0320.00916.95
8.5.30.0360.00617.14
8.5.20.0340.01216.76
8.5.10.0310.00717.01
8.5.00.0120.00617.18
8.4.240.0290.00819.60
8.4.230.0410.00319.71
8.4.220.0280.01019.68
8.4.210.0280.01419.77
8.4.200.0290.01119.77
8.4.190.0350.00819.89
8.4.180.0320.01019.87
8.4.170.0190.00819.87
8.4.160.0170.00719.90
8.4.150.0300.01119.78
8.4.140.0350.00717.93
8.4.130.0370.00717.79
8.4.120.0320.01518.12
8.4.110.0420.00918.10
8.4.100.0310.00717.88
8.4.90.0150.00518.11
8.4.80.0330.00818.24
8.4.70.0310.01218.34
8.4.60.0350.00918.25
8.4.50.0370.00718.09
8.4.40.0300.01417.81
8.4.30.0340.01218.01
8.4.20.0340.00917.98
8.4.10.0350.00718.11
8.3.330.0370.01318.64
8.3.320.0340.00818.55
8.3.310.0320.00918.61
8.3.300.0330.00918.60
8.3.290.0290.01118.68
8.3.280.0340.00718.74
8.3.270.0360.00716.78
8.3.260.0290.01016.91
8.3.250.0340.00816.79
8.3.240.0260.01516.80
8.3.230.0310.01016.81
8.3.220.0270.00616.98
8.3.210.0270.00716.93
8.3.200.0300.00316.79
8.3.190.0390.00816.86
8.3.180.0370.00916.87
8.3.170.0410.00816.61
8.3.160.0340.01016.71
8.3.150.0320.00716.67
8.3.140.0340.00916.86
8.3.130.0310.00716.81
8.3.120.0310.00817.14
8.3.110.0310.00616.88
8.3.100.0370.00816.97
8.3.90.0380.00816.95
8.3.80.0350.00917.01
8.3.70.0360.01017.03
8.3.60.0330.01216.64
8.3.50.0400.00817.03
8.3.40.0420.01218.09
8.3.30.0130.00418.16
8.3.20.0130.00518.03
8.3.10.0310.00518.23
8.3.00.0260.00918.22
8.2.330.0490.00918.22
8.2.320.0330.01318.41
8.2.310.0230.00917.98

preferences:
55.36 ms | 1367 KiB | 5 Q