3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Database {} $fns = [ function ($str) {}, function ($str ="hello") {}, function (string $str) {}, function (string $str = null) {}, function (?string $str) {}, function (?Database $db) {}, function (Database $db = new Database()) {}, function (string|null $str) {}, function (string $str = "hello") {}, function (?string $str = "hello") {}, function (string|int $str) {}, function (string|null $str = null) {}, function (string|null $str = "hello") {}, ]; echo "parameter\tallowsNull\tisOptional\tgetDefaultValue\tgetType\n"; foreach ($fns as $fn) { $param = (new ReflectionFunction($fn))->getParameters()[0]; echo substr($param->__toString(), 26, -2) . "\t" . json_encode($param->allowsNull()) . "\t" . json_encode($param->isOptional()) . "\t" . ($param->isDefaultValueAvailable() ? str_replace("\n", "", print_r($param->getDefaultValue(), true)) : "throws ReflectionException") . "\t" . ($param->getType() ? get_class($param->getType()) : "null") . "\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.3.00.0110.00828.09
8.2.110.0080.00320.24
8.2.100.0020.00918.84
8.0.110.0100.00828.09
7.4.330.0200.00328.09
5.6.400.0080.07625.66

preferences:
128.74 ms | 1398 KiB | 7 Q