3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @author ciid */ #[Attribute(Attribute::TARGET_PROPERTY)] class PropertyAttributes { public function __construct( public readonly ?string $name = null, public readonly ?string $label = null, ) {} } #[Attribute(Attribute::TARGET_PROPERTY)] class IntegerPropertyAttributes extends PropertyAttributes { public function __construct( ?string $name = null, ?string $label = null, public readonly ?int $default = null, public readonly ?int $min = null, public readonly ?int $max = null, public readonly ?int $step = null, ) { parent::__construct($name, $label); } } #[Attribute(Attribute::TARGET_PROPERTY)] class FloatPropertyAttributes extends PropertyAttributes { public function __construct( ?string $name = null, ?string $label = null, public readonly ?float $default = null, public readonly ?float $min = null, public readonly ?float $max = null, ) { parent::__construct($name, $label); } } function buildHtmlFormControl(PropertyAttributes $args): string { $html = []; $html[] = "<label>{$args->label} "; $html[] = "<input"; $html[] = " name=\"{$args->name}\""; $html[] = " value=\"{$args->default}\""; switch ($args::class) { case 'IntegerPropertyAttributes': $html[] = " type=\"number\""; $html[] = " min=\"{$args->min}\""; $html[] = " max=\"{$args->max}\""; $html[] = " step=\"{$args->step}\""; break; case 'FloatPropertyAttributes': $html[] = " type=\"number\""; $html[] = " min=\"{$args->min}\""; $html[] = " max=\"{$args->max}\""; break; } $html[] = "></label>\n"; return implode('', $html); } // model class with properties to edit in UI class MyClass { #[IntegerPropertyAttributes('prop','property: ',5,0,10,1)] public int $prop; #[FloatPropertyAttributes('float','double: ',5.5,0.0,9.9)] public float $double; } // index.php implementation $props = [['MyClass', 'prop'], ['MyClass', 'double']]; foreach ($props as $prop) { $refl = new ReflectionProperty($prop[0], $prop[1]); $reflAttrs = $refl->getAttributes(); foreach ($reflAttrs as $attr) { echo buildHtmlFormControl($attr->newInstance()); } }

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.00.0190.00816.34
8.4.150.0130.00919.75
8.4.140.0300.01117.66
8.4.130.0390.00817.53
8.4.120.0350.01217.80
8.4.110.0300.01317.90
8.4.100.0370.01317.77
8.4.90.0390.01217.68
8.4.80.0370.01017.67
8.4.70.0360.01217.57
8.4.60.0430.00917.74
8.4.50.0430.00717.86
8.4.40.0440.01317.68
8.4.30.0400.00817.57
8.4.20.0360.01217.53
8.4.10.0440.00817.76
8.3.280.0120.01018.45
8.3.270.0360.00716.72
8.3.260.0400.00516.52
8.3.250.0320.01316.62
8.3.240.0380.01016.61
8.3.230.0400.00816.62
8.3.220.0300.01516.64
8.3.210.0370.00916.46
8.3.200.0340.01116.67
8.3.190.0370.00716.75
8.3.180.0380.00816.66
8.3.170.0390.01216.57
8.3.160.0370.00916.59
8.3.150.0430.00616.38
8.3.140.0370.00816.80
8.3.130.0340.00916.61
8.3.120.0370.00916.57
8.3.110.0380.00916.48
8.3.100.0400.00816.66
8.3.90.0420.00916.51
8.3.80.0350.01116.57
8.3.70.0390.01016.71
8.3.60.0400.00816.59
8.3.50.0380.00916.80
8.3.40.0390.00817.73
8.3.30.0260.01217.99
8.3.20.0290.00817.85
8.3.10.0280.00917.60
8.3.00.0300.00717.88
8.2.290.0310.00816.32
8.2.280.0330.00716.42
8.2.270.0350.00816.53
8.2.260.0370.00716.70
8.2.250.0300.00816.72
8.2.240.0310.00816.40
8.2.230.0290.00916.38
8.2.220.0330.00816.52
8.2.210.0360.01016.28
8.2.200.0300.00816.42
8.2.190.0330.01016.70
8.2.180.0330.01216.40
8.2.170.0280.01217.91
8.2.160.0320.00918.00
8.2.150.0340.00817.89
8.2.140.0300.00917.84
8.2.130.0280.01117.71
8.2.120.0260.01117.95
8.2.110.0270.01017.64
8.2.100.0290.00717.96
8.2.90.0330.00817.87
8.2.80.0300.00917.84
8.2.70.0240.01517.73
8.2.60.0320.00517.80
8.2.50.0260.01117.91
8.2.40.0240.01417.69
8.2.30.0280.01117.71
8.2.20.0390.00917.85
8.2.10.0290.00717.91
8.2.00.0300.00617.60

preferences:
31.53 ms | 403 KiB | 5 Q